Annotation of loncom/publisher/loncfile.pm, revision 1.64
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to rename files, etc, in construction space
3: #
1.9 foxr 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: #
1.24 albertel 11: #
1.64 ! albertel 12: # $Id: loncfile.pm,v 1.63 2004/09/10 20:05:03 albertel Exp $
1.7 albertel 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: #
1.12 foxr 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
1.17 harris41 50: space directory listing are clicked. All operations proceed in two phases.
1.12 foxr 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
1.1 www 62:
63: package Apache::loncfile;
64:
65: use strict;
66: use Apache::File;
1.15 foxr 67: use File::Basename;
1.1 www 68: use File::Copy;
1.18 foxr 69: use HTML::Entities();
1.1 www 70: use Apache::Constants qw(:common :http :methods);
71: use Apache::loncacc;
1.9 foxr 72: use Apache::Log ();
1.15 foxr 73: use Apache::lonnet;
1.33 www 74: use Apache::loncommon();
1.47 sakharuk 75: use Apache::lonlocal;
1.9 foxr 76:
1.45 taceyjo1 77: my $DEBUG=0;
1.10 foxr 78: my $r; # Needs to be global for some stuff RF.
1.12 foxr 79:
80: =pod
81:
82: =item Debug($request, $message)
83:
1.17 harris41 84: If debugging is enabled puts out a debugging message determined by the
1.12 foxr 85: caller. The debug message goes to the Apache error log file. Debugging
1.17 harris41 86: is enabled by setting the module global DEBUG variable to nonzero (TRUE).
1.12 foxr 87:
88: Parameters:
89:
90: =over 4
91:
1.17 harris41 92: =item $request - The current request operation.
1.12 foxr 93:
1.17 harris41 94: =item $message - The message to put in the log file.
1.12 foxr 95:
96: =back
97:
98: Returns:
99: nothing.
100:
101: =cut
102:
1.9 foxr 103: sub Debug {
1.12 foxr 104:
1.55 albertel 105: # Marshall the parameters.
1.12 foxr 106:
1.55 albertel 107: my $r = shift;
108: my $log = $r->log;
109: my $message = shift;
1.12 foxr 110:
1.55 albertel 111: # Put out the indicated message butonly if DEBUG is true.
1.12 foxr 112:
1.55 albertel 113: if ($DEBUG) {
114: $r->log_reason($message);
115: }
1.12 foxr 116: }
117:
118: =pod
119:
120: =item URLToPath($url)
121:
122: Convert a URL to a file system path.
123:
124: In order to manipulate the construction space objects, it is necessary
125: to access url identified objects a filespace objects. This function
126: translates a construction space URL to a file system path.
127: Parameters:
128:
129: =over 4
130:
131: =item Url - string [in] The url to convert.
132:
133: =back
134:
135: Returns:
136:
137: =over 4
138:
1.16 harris41 139: =item The corresponding file system path.
1.12 foxr 140:
141: =back
142:
143: Global References
144:
145: =over 4
146:
147: =item $r - Request object [in] Referenced in the &Debug calls.
148:
149: =back
150:
151: =cut
152:
153: sub URLToPath {
1.55 albertel 154: my $Url = shift;
155: &Debug($r, "UrlToPath got: $Url");
156: $Url=~ s/\/+/\//g;
157: $Url=~ s/^http\:\/\/[^\/]+//;
158: $Url=~ s/^\///;
159: $Url=~ s/(\~|priv\/)(\w+)\//\/home\/$2\/public_html\//;
160: &Debug($r, "Returning $Url \n");
161: return $Url;
1.12 foxr 162: }
163:
1.36 www 164: sub url {
165: my $fn=shift;
166: $fn=~s/^\/home\/(\w+)\/public\_html/\/priv\/$1/;
1.56 albertel 167: $fn=&HTML::Entities::encode($fn,'<>"&');
1.36 www 168: return $fn;
169: }
170:
171: sub display {
172: my $fn=shift;
1.43 albertel 173: $fn=~s-^/home/(\w+)/public_html-/priv/$1-;
1.36 www 174: return '<tt>'.$fn.'</tt>';
175: }
176:
1.50 www 177:
178: # see if the file is
179: # a) published (return 0 if not)
180: # b) if, so obsolete (return 0 if not)
181:
182: sub obsolete_unpub {
183: my ($user,$domain,$construct)=@_;
184: my $published=$construct;
185: $published=~
186: s/^\/home\/$user\/public\_html\//\/home\/httpd\/html\/res\/$domain\/$user\//;
187: if (-e $published) {
188: if (&Apache::lonnet::metadata($published,'obsolete')) {
189: return 1;
190: }
191: return 0;
192: } else {
193: return 1;
194: }
195: }
196:
197:
198:
1.12 foxr 199: =pod
200:
1.39 www 201: =item exists($user, $domain, $file)
1.12 foxr 202:
1.17 harris41 203: Determine if a resource file name has been published or exists
1.12 foxr 204: in the construction space.
205:
206: Parameters:
207:
208: =over 4
209:
210: =item $user - string [in] - Name of the user for which to check.
211:
212: =item $domain - string [in] - Name of the domain in which the resource
213: might have been published.
214:
215: =item $file - string [in] - Name of the file.
216:
217: =back
218:
219: Returns:
220:
221: =over 4
222:
223: =item string - Either where the resource exists as an html string that can
224: be embedded in a dialog or an empty string if the resource
225: does not exist.
226:
227: =back
228:
229: =cut
230:
1.8 albertel 231: sub exists {
1.55 albertel 232: my ($user, $domain, $construct) = @_;
233: my $published=$construct;
234: $published=~
235: s/^\/home\/$user\/public\_html\//\/home\/httpd\/html\/res\/$domain\/$user\//;
236: my $result='';
237: if ( -d $construct ) {
238: return &mt('Error: destination for operation is an existing directory.');
239: }
240: if ( -e $published) {
241: $result.='<p><font color="red">'.&mt('Warning: target file exists, and has been published!').'</font></p>';
242: } elsif ( -e $construct) {
243: $result.='<p><font color="red">'.&mt('Warning: target file exists!').'</font></p>';
244: }
245: return $result;
1.8 albertel 246: }
247:
1.12 foxr 248: =pod
249:
250: =item checksuffix($old, $new)
251:
252: Determine if a resource filename suffix (the stuff after the .) would change
253: as a result of this operation.
254:
255: Parameters:
256:
257: =over 4
258:
259: =item $old = string [in] Previous filename.
260:
261: =item $new = string [in] Resultant filename.
262:
263: =back
264:
265: Returns:
266:
267: =over 4
268:
1.17 harris41 269: =item Empty string if everything worked.
1.12 foxr 270:
271: =item String containing an error message if there was a problem.
272:
273: =back
274:
275: =cut
276:
1.8 albertel 277: sub checksuffix {
278: my ($old,$new) = @_;
279: my $result;
280: my $oldsuffix;
281: my $newsuffix;
282: if ($new=~m:(.*/*)([^/]+)\.(\w+)$:) { $newsuffix=$3; }
283: if ($old=~m:(.*)/+([^/]+)\.(\w+)$:) { $oldsuffix=$3; }
284: if ($oldsuffix ne $newsuffix) {
1.12 foxr 285: $result.=
1.47 sakharuk 286: '<p><font color="red">'.&mt('Warning: change of MIME type!').'</font></p>';
1.8 albertel 287: }
288: return $result;
289: }
1.32 albertel 290:
291: sub cleanDest {
1.64 ! albertel 292: my ($request,$dest,$subdir,$fn,$uname)=@_;
1.32 albertel 293: #remove bad characters
1.58 albertel 294: my $foundbad=0;
295: if ($subdir && $dest =~/\./) {
296: $foundbad=1;
297: $dest=~s/\.//g;
298: }
1.57 albertel 299: if ($dest=~/[\#\?&%\"]/) {
1.58 albertel 300: $foundbad=1;
1.59 albertel 301: $dest=~s/[\#\?&%\"]//g;
1.58 albertel 302: }
1.63 albertel 303: if ($dest=~m|/|) {
304: my ($newpath)=($dest=~m|(.*)/|);
1.64 ! albertel 305: $newpath=&relativeDest($fn,$newpath,$uname);
! 306: if (! -d "$newpath") {
! 307: $request->print("<p><font color=\"red\">".&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.','"<tt>'.$newpath.'</tt>"')."</font></p>");
1.63 albertel 308: $dest=~s|.*/||;
309: }
310: }
1.58 albertel 311: if ($foundbad) {
1.47 sakharuk 312: $request->print("<p><font color=\"red\">".&mt('Invalid characters in requested name have been removed.')."</font></p>");
1.32 albertel 313: }
314: return $dest;
315: }
316:
1.36 www 317: sub relativeDest {
318: my ($fn,$newfilename,$uname)=@_;
319: if ($newfilename=~/^\//) {
320: # absolute, simply add path
321: $newfilename='/home/'.$uname.'/public_html/';
322: } else {
323: my $dir=$fn;
324: $dir=~s/\/[^\/]+$//;
325: $newfilename=$dir.'/'.$newfilename;
326: }
327: $newfilename=~s://+:/:g; # remove duplicate /
328: while ($newfilename=~m:/\.\./:) {
329: $newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
330: }
331: return $newfilename;
332: }
333:
1.12 foxr 334: =pod
335:
336: =item CloseForm1($request, $user, $file)
337:
338: Close of a form on the successful completion of phase 1 processing
339:
340: Parameters:
341:
342: =over 4
343:
344: =item $request - Apache Request Object [in] - Apache server request object.
345:
1.13 foxr 346: =item $cancelurl - the url to go to on cancel.
1.12 foxr 347:
348: =back
349:
350: =cut
351:
352: sub CloseForm1 {
1.55 albertel 353: my ($request, $fn) = @_;
354: $request->print('<p><input type="submit" value="'.&mt('Continue').'" /></p></form>');
355: $request->print('<form action="'.&url($fn).
356: '" method="POST"><p><input type="submit" value="'.&mt('Cancel').'" /></p></form>');
1.12 foxr 357: }
358:
359:
360: =pod
361:
362: =item CloseForm2($request, $user, $directory)
363:
364: Successfully close off the phase 2 form.
365:
366: Parameters:
367:
368: =over 4
369:
370: =item $request - Apache Request object [in] - The request that is being
371: executed.
372:
373: =item $user - string [in] - Name of the user that is initiating the
374: request.
375:
376: =item $directory - string [in] - Directory in which the operation is
377: being done relative to the top level construction space
378: directory.
379:
380: =back
381:
382: =cut
383:
384: sub CloseForm2 {
1.55 albertel 385: my ($request, $user, $fn) = @_;
386: $request->print('<h3><a href="'.&url($fn).'/">'.&mt('Done').'</a></h3>');
1.12 foxr 387: }
388:
389: =pod
390:
391: =item Rename1($request, $filename, $user, $domain, $dir)
392:
393: Perform phase 1 processing of the file rename operation.
394:
395: Parameters:
396:
397: =over 4
398:
399: =item $request - Apache Request Object [in] The request object for the
400: current request.
401:
402: =item $filename - The filename relative to construction space.
403:
404: =item $user - Name of the user making the request.
405:
406: =item $domain - User login domain.
407:
408: =item $dir - Directory specification of the path to the file.
409:
410: =back
411:
412: Side effects:
413:
414: =over 4
415:
416: =item A new form is displayed prompting for confirmation. The newfilename
417: hidden field of this form is loaded with
418: new filename relative to the current directory ($dir).
419:
420: =back
421:
422: =cut
423:
424: sub Rename1 {
1.52 albertel 425: my ($request, $user, $domain, $fn, $newfilename, $style) = @_;
1.36 www 426:
427: if(-e $fn) {
428: if($newfilename) {
1.42 albertel 429: # is dest a dir
1.52 albertel 430: if ($style eq 'move') {
431: if (-d $newfilename) {
432: if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; }
433: }
1.42 albertel 434: }
1.29 albertel 435: if ($newfilename =~ m|/[^\.]+$|) {
1.36 www 436: #no extension add on original extension
437: if ($fn =~ m|/[^\.]*\.([^\.]+)$|) {
1.24 albertel 438: $newfilename.='.'.$1;
439: }
440: }
1.36 www 441: $request->print(&checksuffix($fn, $newfilename));
1.27 albertel 442: #renaming a dir, delete the trailing /
1.39 www 443: #remove second to last element for current dir
444: if (-d $fn) {
1.53 www 445: $newfilename=~/\.(\w+)$/;
446: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
447: $request->print('<br /><font color="red">'.
1.55 albertel 448: &mt('Cannot change MIME type of a directory').
1.53 www 449: '</font>'.
1.55 albertel 450: '<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>');
1.53 www 451: return;
452: }
1.39 www 453: $newfilename=~s/\/[^\/]+\/([^\/]+)$/\/$1/;
1.27 albertel 454: }
1.42 albertel 455: $newfilename=~s://+:/:g; # remove duplicate /
456: while ($newfilename=~m:/\.\./:) {
457: $newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
458: }
1.39 www 459: my $return=&exists($user, $domain, $newfilename);
1.21 albertel 460: $request->print($return);
461: if ($return =~/^Error:/) {
1.47 sakharuk 462: $request->print('<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>');
1.21 albertel 463: return;
464: }
1.50 www 465: unless (&obsolete_unpub($user,$domain,$fn)) {
466: $request->print('<h3>'.&mt('Cannot rename or move non-obsolete published file').'</h3>'.
467: '<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>');
468: return;
469: }
1.52 albertel 470: my $action;
471: if ($style eq 'rename') {
472: $action=&mt('Rename');
473: } else {
474: $action=&mt('Move');
475: }
1.23 albertel 476: $request->print('<input type="hidden" name="newfilename" value="'.
1.12 foxr 477: $newfilename.
1.52 albertel 478: '" /><p>'.$action.' '.&display($fn).
1.36 www 479: '</tt><br />to '.&display($newfilename).'?</p>');
480: &CloseForm1($request, $fn);
1.12 foxr 481: } else {
1.47 sakharuk 482: $request->print('<p>'.&mt('No new filename specified.').'</p></form>');
1.12 foxr 483: return;
484: }
485: } else {
1.47 sakharuk 486: $request->print('<p> '.&mt('No such file').': '.&display($fn).'</p></form>');
1.12 foxr 487: return;
488: }
489:
490: }
1.55 albertel 491:
1.12 foxr 492: =pod
493:
494: =item Delete1
495:
496: Performs phase 1 processing of the delete operation. In phase one
497: we just check to be sure the file exists.
498:
499: Parameters:
500:
501: =over 4
502:
1.36 www 503: =item $request - Apache Request Object [in] request object for the current
1.12 foxr 504: request.
505:
1.36 www 506: =item $user - string [in] Name of the user initiating the request.
1.12 foxr 507:
1.36 www 508: =item $domain - string [in] Domain the initiating user is logged in as
1.13 foxr 509:
1.36 www 510: =item $filename - string [in] Source filename.
1.12 foxr 511:
512: =back
513:
514: =cut
515:
516: sub Delete1 {
1.55 albertel 517: my ($request, $user, $domain, $fn) = @_;
1.12 foxr 518:
1.55 albertel 519: if( -e $fn) {
520: $request->print('<input type="hidden" name="newfilename" value="'.
521: $fn.'"/>');
522: unless (&obsolete_unpub($user,$domain,$fn)) {
523: $request->print('<h3>'.&mt('Cannot delete non-obsolete published file').'</h3>'.
524: '<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>');
525: return;
526: }
527: $request->print('<p>'.&mt('Delete').' '.&display($fn).'?</p>');
528: &CloseForm1($request, $fn);
529: } else {
530: $request->print('<p>'.&mt('No such file').': '.&display($fn).'</p></form>');
1.50 www 531: }
1.12 foxr 532: }
533:
534: =pod
535:
536: =item Copy1($request, $user, $domain, $filename, $newfilename)
537:
538: Performs phase 1 processing of the construction space copy command.
1.17 harris41 539: Ensure that the source file exists. Ensure that a destination exists,
540: also warn if the destination already exists.
1.12 foxr 541:
542: Parameters:
543:
544: =over 4
545:
546: =item $request - Apache Request Object [in] request object for the current
547: request.
548:
549: =item $user - string [in] Name of the user initiating the request.
550:
551: =item $domain - string [in] Domain the initiating user is logged in as
552:
1.36 www 553: =item $fn - string [in] Source filename.
1.12 foxr 554:
555: =item $newfilename-string [in] Destination filename.
556:
557: =back
558:
559: =cut
560:
561: sub Copy1 {
1.42 albertel 562: my ($request, $user, $domain, $fn, $newfilename) = @_;
1.12 foxr 563:
1.42 albertel 564: if(-e $fn) {
565: # is dest a dir
566: if (-d $newfilename) {
567: if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; }
568: }
569: if ($newfilename =~ m|/[^\.]+$|) {
570: #no extension add on original extension
571: if ($fn =~ m|/[^\.]*\.([^\.]+)$|) { $newfilename.='.'.$1; }
572: }
573: $newfilename=~s://+:/:g; # remove duplicate /
574: while ($newfilename=~m:/\.\./:) {
575: $newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
576: }
577: $request->print(&checksuffix($fn,$newfilename));
578: my $return=&exists($user, $domain, $newfilename);
579: $request->print($return);
580: if ($return =~/^Error:/) {
1.47 sakharuk 581: $request->print('<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>');
1.42 albertel 582: return;
583: }
584: $request->print('<input type="hidden" name="newfilename" value="'.
585: $newfilename.
1.47 sakharuk 586: '" /><p>'.&mt('Copy').' '.&display($fn).'<br />to '.
1.42 albertel 587: &display($newfilename).'?</p>');
588: &CloseForm1($request, $fn);
589: } else {
1.47 sakharuk 590: $request->print('<p>'.&mt('No such file').': '.&display($fn).'</p></form>');
1.21 albertel 591: }
1.19 albertel 592: }
593:
594: =pod
595:
1.12 foxr 596: =item NewDir1
597:
598: Does all phase 1 processing of directory creation:
599: Ensures that the user provides a new directory name,
600: and that the directory does not already exist.
601:
602: Parameters:
603:
604: =over 4
605:
606: =item $request - Apache Request Object [in] - Server request object for the
1.17 harris41 607: current url.
1.12 foxr 608:
609: =item $username - Name of the user that is requesting the directory creation.
610:
1.36 www 611: =item $domain - Domain user is in
612:
613: =item $fn - source file.
1.12 foxr 614:
615: =item $newdir - Name of the directory to be created; path relative to the
616: top level of construction space.
617: =back
618:
619: Side Effects:
620:
621: =over 4
622:
623: =item A new form is displayed. Clicking on the confirmation button
624: causes the newdir operation to transition into phase 2. The hidden field
625: "newfilename" is set with the construction space path to the new directory.
626:
627:
628: =back
629:
630: =cut
631:
632:
1.55 albertel 633: sub NewDir1 {
634: my ($request, $username, $domain, $fn, $newfilename, $mode) = @_;
635:
636: my $result=&exists($username,$domain,$newfilename);
637: if ($result) {
638: $request->print('<font color="red">'.$result.'</font></form>');
639: } else {
640: if ($mode eq 'testbank') {
641: $request->print('<input type="hidden" name="callingmode" value="testbank">');
642: } elsif ($mode eq 'imsimport') {
643: $request->print('<input type="hidden" name="callingmode" value="imsimport">');
644: }
645: $request->print('<input type="hidden" name="newfilename" value="'.
646: $newfilename.'" /><p>'.&mt('Make new directory').' '.
647: &display($newfilename).'?</p>');
648: &CloseForm1($request, $fn);
649: }
1.12 foxr 650: }
651:
1.44 taceyjo1 652:
653: sub Decompress1 {
1.55 albertel 654: my ($request, $user, $domain, $fn) = @_;
655: if( -e $fn) {
1.44 taceyjo1 656: $request->print('<input type="hidden" name="newfilename" value="'.$fn.'"/>');
1.47 sakharuk 657: $request->print('<p>'.&mt('Decompress').' '.&display($fn).'?</p>');
1.44 taceyjo1 658: &CloseForm1($request, $fn);
1.55 albertel 659: } else {
660: $request->print('<p>'.&mt('No such file').': '.&display($fn).'</p></form>');
661: }
1.44 taceyjo1 662: }
1.55 albertel 663:
1.12 foxr 664: =pod
665:
1.22 albertel 666: =item NewFile1
667:
668: Does all phase 1 processing of file creation:
669: Ensures that the user provides a new filename, adds proper extension
670: if needed and that the file does not already exist, if it is a html,
671: problem, page, or sequence, it then creates a form link to hand the
672: actual creation off to the proper handler.
673:
674: Parameters:
675:
676: =over 4
677:
678: =item $request - Apache Request Object [in] - Server request object for the
679: current url.
680:
681: =item $username - Name of the user that is requesting the directory creation.
682:
683: =item $domain - Name of the domain of the user
684:
1.36 www 685: =item $fn - Source file name
1.22 albertel 686:
687: =item $newfilename
688: - Name of the file to be created; no path information
689: =back
690:
691: Side Effects:
692:
693: =over 4
694:
695: =item 2 new forms are displayed. Clicking on the confirmation button
696: causes the browser to attempt to load the specfied URL, allowing the
1.36 www 697: proper handler to take care of file creation. There is also a Cancel
1.22 albertel 698: button which returns you to the driectory listing you came from
699:
700: =back
701:
702: =cut
703:
704: sub NewFile1 {
1.36 www 705: my ($request, $user, $domain, $fn, $newfilename) = @_;
1.22 albertel 706:
707: if ($ENV{'form.action'} =~ /new(.+)file/) {
708: my $extension=$1;
1.40 www 709:
710: ##Informs User (name).(number).(extension) not allowed
711: if($newfilename =~ /\.(\d+)\.(\w+)$/){
712: $r->print('<font color="red">'.$newfilename.
1.47 sakharuk 713: ' - '.&mt('Bad Filename').'<br />('.&mt('name').').('.&mt('number').').('.&mt('extension').')'.
714: ' '.&mt('Not Allowed').'</font>');
1.40 www 715: return;
716: }
1.22 albertel 717: if ($newfilename !~ /\Q.$extension\E$/) {
1.26 albertel 718: if ($newfilename =~ m|^[^\.]*\.([^\.]+)$|) {
719: #already has an extension strip it and add in expected one
720: $newfilename =~ s|.([^\.]+)$||;
721: }
1.22 albertel 722: $newfilename.=".$extension";
723: }
1.31 albertel 724: }
1.39 www 725: my $result=&exists($user,$domain,$newfilename);
726: if($result) {
727: $request->print('<font color="red">'.$result.'</font></form>');
728: } else {
1.47 sakharuk 729: $request->print('<p>'.&mt('Make new file').' '.&display($newfilename).'?</p>');
1.22 albertel 730: $request->print('</form>');
1.36 www 731: $request->print('<form action="'.&url($newfilename).
1.47 sakharuk 732: '" method="POST"><p><input type="submit" value="'.&mt('Continue').'" /></p></form>');
1.36 www 733: $request->print('<form action="'.&url($fn).
1.47 sakharuk 734: '" method="POST"><p><input type="submit" value="'.&mt('Cancel').'" /></p></form>');
1.22 albertel 735: }
736: }
737:
738: =pod
739:
1.12 foxr 740: =item phaseone($r, $fn, $uname, $udom)
741:
742: Peforms phase one processing of the request. In phase one, error messages
743: are returned if the request cannot be performed (e.g. attempts to manipulate
744: files that are nonexistent). If the operation can be performed, what is
745: about to be done will be presented to the user for confirmation. If the
746: user confirms the request, then phase two is executed, the action
747: performed and reported to the user.
748:
749: Parameters:
750:
751: =over 4
752:
753: =item $r - request object [in] - The Apache request being executed.
754:
755: =item $fn = string [in] - The filename being manipulated by the
756: request.
757:
758: =item $uname - string [in] Name of user logged in and doing this action.
759:
1.17 harris41 760: =item $udom - string [in] Domain name under which the user logged in.
1.12 foxr 761:
762: =back
763:
764: =cut
1.8 albertel 765:
1.1 www 766: sub phaseone {
1.55 albertel 767: my ($r,$fn,$uname,$udom)=@_;
1.12 foxr 768:
1.58 albertel 769: my $doingdir=0;
770: if ($ENV{'form.action'} eq 'newdir') { $doingdir=1; }
1.64 ! albertel 771: my $newfilename=&cleanDest($r,$ENV{'form.newfilename'},$doingdir,$fn,$uname);
1.55 albertel 772: $newfilename=&relativeDest($fn,$newfilename,$uname);
773: $r->print('<form action="/adm/cfile" method="post">'.
774: '<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'.
775: '<input type="hidden" name="phase" value="two" />'.
776: '<input type="hidden" name="action" value="'.$ENV{'form.action'}.'" />');
1.12 foxr 777:
1.55 albertel 778: if ($ENV{'form.action'} eq 'rename') {
779: &Rename1($r, $uname, $udom, $fn, $newfilename, 'rename');
780: } elsif ($ENV{'form.action'} eq 'move') {
781: &Rename1($r, $uname, $udom, $fn, $newfilename, 'move');
782: } elsif ($ENV{'form.action'} eq 'delete') {
783: &Delete1($r, $uname, $udom, $fn);
784: } elsif ($ENV{'form.action'} eq 'decompress') {
785: &Decompress1($r, $uname, $udom, $fn);
786: } elsif ($ENV{'form.action'} eq 'copy') {
787: if($newfilename) {
788: &Copy1($r, $uname, $udom, $fn, $newfilename);
789: } else {
790: $r->print('<p>'.&mt('No new filename specified.').'</p></form>');
791: }
792: } elsif ($ENV{'form.action'} eq 'newdir') {
793: my $mode = '';
794: if (exists($ENV{'form.callingmode'}) ) {
795: $mode = $ENV{'form.callingmode'};
796: }
797: &NewDir1($r, $uname, $udom, $fn, $newfilename, $mode);
798: } elsif ($ENV{'form.action'} eq 'newfile' ||
799: $ENV{'form.action'} eq 'newhtmlfile' ||
800: $ENV{'form.action'} eq 'newproblemfile' ||
801: $ENV{'form.action'} eq 'newpagefile' ||
802: $ENV{'form.action'} eq 'newsequencefile' ||
803: $ENV{'form.action'} eq 'newrightsfile' ||
804: $ENV{'form.action'} eq 'newstyfile' ||
805: $ENV{'form.action'} eq 'Select Action') {
806: if ($newfilename) {
807: &NewFile1($r, $uname, $udom, $fn, $newfilename);
808: } else {
809: $r->print('<p>'.&mt('No new filename specified.').'</p></form>');
810: }
811: }
1.12 foxr 812: }
813:
814: =pod
815:
816: =item Rename2($request, $user, $directory, $oldfile, $newfile)
817:
1.17 harris41 818: Performs phase 2 processing of a rename reequest. This is where the
1.12 foxr 819: actual rename is performed.
820:
821: Parameters
822:
823: =over 4
824:
825: =item $request - Apache request object [in] The request being processed.
826:
827: =item $user - string [in] The name of the user initiating the request.
828:
829: =item $directory - string [in] The name of the directory relative to the
830: construction space top level of the renamed file.
831:
832: =item $oldfile - Name of the file.
833:
834: =item $newfile - Name of the new file.
835:
836: =back
837:
838: Returns:
839:
840: =over 4
841:
842: =item 1 Success.
843:
844: =item 0 Failure.
845:
846: =cut
847:
848: sub Rename2 {
849:
1.55 albertel 850: my ($request, $user, $directory, $oldfile, $newfile) = @_;
1.12 foxr 851:
1.55 albertel 852: &Debug($request, "Rename2 directory: ".$directory." old file: ".$oldfile.
853: " new file ".$newfile."\n");
854: &Debug($request, "Target is: ".$directory.'/'.
855: $newfile);
856: if (-e $oldfile) {
857:
858: my $oRN=$oldfile;
859: my $nRN=$newfile;
860: unless (rename($oldfile,$newfile)) {
861: $request->print('<font color="red">'.&mt('Error').': '.$!.'</font>');
862: return 0;
863: }
864: ## If old name.(extension) exits, move under new name.
865: ## If it doesn't exist and a new.(extension) exists
866: ## delete it (only concern when renaming over files)
867: my $tmp1=$oRN.'.meta';
868: my $tmp2=$nRN.'.meta';
869: if(-e $tmp1){
870: unless(rename($tmp1,$tmp2)){ }
871: } elsif(-e $tmp2){
872: unlink $tmp2;
873: }
874: $tmp1=$oRN.'.save';
875: $tmp2=$nRN.'.save';
876: if(-e $tmp1){
877: unless(rename($tmp1,$tmp2)){ }
878: } elsif(-e $tmp2){
879: unlink $tmp2;
880: }
881: $tmp1=$oRN.'.log';
882: $tmp2=$nRN.'.log';
883: if(-e $tmp1){
884: unless(rename($tmp1,$tmp2)){ }
885: } elsif(-e $tmp2){
886: unlink $tmp2;
887: }
888: $tmp1=$oRN.'.bak';
889: $tmp2=$nRN.'.bak';
890: if(-e $tmp1){
891: unless(rename($tmp1,$tmp2)){ }
892: } elsif(-e $tmp2){
893: unlink $tmp2;
894: }
895: } else {
896: $request->print("<p> ".&mt('No such file').": ".&display($oldfile).'</p></form>');
897: return 0;
898: }
899: return 1;
1.12 foxr 900: }
1.55 albertel 901:
1.12 foxr 902: =pod
903:
904: =item Delete2($request, $user, $filename)
905:
906: Performs phase two of a delete. The user has confirmed that they want
907: to delete the selected file. The file is deleted and the results of the
908: delete attempt are indicated.
909:
910: Parameters:
911:
912: =over 4
913:
914: =item $request - Apache Request object [in] the request object for the current
915: delete operation.
916:
917: =item $user - string [in] The name of the user initiating the delete
918: request.
919:
1.17 harris41 920: =item $filename - string [in] The name of the file, relative to construction
921: space, to delete.
1.12 foxr 922:
923: =back
924:
925: Returns:
926: 1 - success.
927: 0 - Failure.
928:
929: =cut
930:
931: sub Delete2 {
1.55 albertel 932: my ($request, $user, $filename) = @_;
933: if(opendir DIR, $filename) {
934: my @files=readdir(DIR);
935: shift @files; shift @files; # takes off . and ..
936: if(@files) {
937: $request->print('<font color="red"> '.&mt('Error: Directory Non Empty').'</font>');
938: return 0;
939: } else {
940: if(-e $filename) {
941: unless(rmdir($filename)) {
942: $request->print('<font color="red">'.&mt('Error').': '.$!.'</font>');
943: return 0;
944: }
945: } else {
946: $request->print('<p> '.&mt('No such file').'. </p></form>');
947: return 0;
948: }
949: }
1.48 taceyjo1 950: } else {
1.55 albertel 951: if(-e $filename) {
952: unless(unlink($filename)) {
953: $request->print('<font color="red">'.&mt('Error').': '.$!.'</font>');
954: return 0;
955: }
956: } else {
957: $request->print('<p> '.&mt('No such file').'. </p></form>');
958: return 0;
1.46 taceyjo1 959: }
1.55 albertel 960: }
961: return 1;
1.12 foxr 962: }
963:
964: =pod
965:
966: =item Copy2($request, $username, $dir, $oldfile, $newfile)
967:
968: Performs phase 2 of a copy. The file is copied and the status
969: of that copy is reported back to the user.
970:
971: =over 4
972:
973: =item $request - Apache request object [in]; the apache request currently
974: being executed.
975:
976: =item $username - string [in] Name of the user who is requesting the copy.
977:
978: =item $dir - string [in] Directory path relative to the construction space
979: of the destination file.
980:
981: =item $oldfile - string [in] Name of the source file.
982:
983: =item $newfile - string [in] Name of the destination file.
984:
985:
986: =back
987:
988: Returns 0 failure, and 0 successs.
989:
990: =cut
1.1 www 991:
1.12 foxr 992: sub Copy2 {
993: my ($request, $username, $dir, $oldfile, $newfile) = @_;
994: &Debug($request ,"Will try to copy $oldfile to $newfile");
995: if(-e $oldfile) {
996: unless (copy($oldfile, $newfile)) {
1.47 sakharuk 997: $request->print('<font color="red"> '.&mt('copy Error').': '.$!.'</font>');
1.12 foxr 998: return 0;
1.61 albertel 999: } elsif (!chmod(0660, $newfile)) {
1000: $request->print('<font color="red"> '.&mt('chmod error').': '.$!.'</font>');
1001: return 0;
1002: } elsif (-e $oldfile.'.meta' &&
1003: !copy($oldfile.'.meta', $newfile.'.meta') &&
1004: !chmod(0660, $newfile.'.meta')) {
1005: $request->print('<font color="red"> '.&mt('copy metadata error').
1006: ': '.$!.'</font>');
1007: return 0;
1.12 foxr 1008: } else {
1009: return 1;
1010: }
1.11 albertel 1011: } else {
1.47 sakharuk 1012: $request->print('<p> '.&mt('No such file').' </p>');
1.12 foxr 1013: return 0;
1.11 albertel 1014: }
1.12 foxr 1015: return 1;
1016: }
1.55 albertel 1017:
1.12 foxr 1018: =pod
1019:
1020: =item NewDir2($request, $user, $newdirectory)
1.1 www 1021:
1.12 foxr 1022: Performs phase 2 processing of directory creation. This involves creating the directory and
1023: reporting the results of that creation to the user.
1024:
1025: Parameters:
1026: =over 4
1027:
1028: =item $request - Apache request object [in]. Object representing the current HTTP request.
1029:
1030: =item $user - string [in] The name of the user that is initiating the request.
1031:
1032: =item $newdirectory - string [in] The full path of the directory being created.
1033:
1034: =back
1035:
1036: Returns 0 - failure 1 - success.
1037:
1038: =cut
1.8 albertel 1039:
1.12 foxr 1040: sub NewDir2 {
1.55 albertel 1041: my ($request, $user, $newdirectory) = @_;
1.12 foxr 1042:
1.55 albertel 1043: unless(mkdir($newdirectory, 02770)) {
1044: $request->print('<font color="red">'.&mt('Error').': '.$!.'</font>');
1045: return 0;
1046: }
1047: unless(chmod(02770, ($newdirectory))) {
1048: $request->print('<font color="red"> '.&mt('Error').': '.$!.'</font>');
1049: return 0;
1050: }
1051: return 1;
1.1 www 1052: }
1.55 albertel 1053:
1.44 taceyjo1 1054: sub decompress2 {
1.55 albertel 1055: my ($r, $user, $dir, $file) = @_;
1056: &Apache::lonnet::appenv('cgi.file' => $file);
1057: &Apache::lonnet::appenv('cgi.dir' => $dir);
1058: my $result=&Apache::lonnet::ssi_body('/cgi-bin/decompress.pl');
1059: $r->print($result);
1060: &Apache::lonnet::delenv('cgi.file');
1061: &Apache::lonnet::delenv('cgi.dir');
1062: return 1;
1.44 taceyjo1 1063: }
1.55 albertel 1064:
1.12 foxr 1065: =pod
1066:
1067: =item phasetwo($r, $fn, $uname, $udom)
1068:
1069: Controls the phase 2 processing of file management
1070: requests for construction space. In phase one, the user
1071: was asked to confirm the operation. In phase 2, the operation
1072: is performed and the result is shown.
1073:
1074: The strategy is to break out the processing into specific action processors
1075: named action2 where action is the requested action and the 2 denotes
1076: phase 2 processing.
1077:
1078: Parameters:
1079:
1080: =over 4
1081:
1082: =item $r - Apache Request object [in] The request object for this httpd
1083: transaction.
1084:
1085: =item $fn - string [in] A filename indicating the object that is being
1086: manipulated.
1087:
1088: =item $uname - string [in] The name of the user initiating the file management
1089: request.
1090:
1091: =item $udom - string [in] The login domain of the user initiating the
1092: file management request.
1093: =back
1094:
1095: =cut
1096:
1.1 www 1097: sub phasetwo {
1098: my ($r,$fn,$uname,$udom)=@_;
1.12 foxr 1099:
1.9 foxr 1100: &Debug($r, "loncfile - Entering phase 2 for $fn");
1.12 foxr 1101:
1102: # Break down the file into it's component pieces.
1103:
1.27 albertel 1104: my $dir; # Directory path
1105: my $main; # Filename.
1106: my $suffix; # Extension.
1.46 taceyjo1 1107: if ($fn=~m:(.*)/([^/]+):) {
1.27 albertel 1108: $dir=$1; # Directory path
1109: $main=$2; # Filename.
1.54 albertel 1110: }
1111: if($main=~m:\.(\w+)$:){ # Fixes problems with filenames with no extensions
1112: $main=$`; #This is what is before the match (.) so it's just the main filename, yea it's nasty
1113: $suffix=$1; #This is the actually filename extension if it exists
1114: }
1.12 foxr 1115: my $dest; # On success this is where we'll go.
1.9 foxr 1116:
1.55 albertel 1117: &Debug($r,"loncfile::phase2 dir = $dir main = $main suffix = $suffix");
1118: &Debug($r," newfilename = ".$ENV{'form.newfilename'});
1.9 foxr 1119:
1120: my $conspace=$fn;
1.12 foxr 1121:
1.55 albertel 1122: &Debug($r,"loncfile::phase2 Full construction space name: $conspace");
1.12 foxr 1123:
1.55 albertel 1124: &Debug($r,"loncfie::phase2 action is $ENV{'form.action'}");
1.12 foxr 1125:
1126: # Select the appropriate processing sub.
1.44 taceyjo1 1127: if ($ENV{'form.action'} eq 'decompress') {
1128: $main .= '.';
1129: $main .= $suffix;
1.55 albertel 1130: if(!&decompress2($r, $uname, $dir, $main)) {
1131: return ;
1132: }
1133: $dest = $dir."/.";
1.62 albertel 1134: } elsif ($ENV{'form.action'} eq 'rename' ||
1135: $ENV{'form.action'} eq 'move') {
1.12 foxr 1136: if($ENV{'form.newfilename'}) {
1.27 albertel 1137: if (!defined($dir)) {
1138: $fn=~m:^(.*)/:;
1.55 albertel 1139: $dir=$1;
1.27 albertel 1140: }
1.12 foxr 1141: if(!&Rename2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) {
1142: return;
1143: }
1.56 albertel 1144: $dest = $ENV{'form.newfilename'};
1.12 foxr 1145: }
1.5 www 1146: } elsif ($ENV{'form.action'} eq 'delete') {
1.12 foxr 1147: if(!&Delete2($r, $uname, $ENV{'form.newfilename'})) {
1148: return ;
1149: }
1150: # Once a resource is deleted, we just list the directory that
1151: # previously held it.
1152: #
1.20 albertel 1153: $dest = $dir."/."; # Parent dir.
1.5 www 1154: } elsif ($ENV{'form.action'} eq 'copy') {
1.12 foxr 1155: if($ENV{'form.newfilename'}) {
1156: if(!&Copy2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) {
1.44 taceyjo1 1157: return ;
1.55 albertel 1158: }
1.12 foxr 1159: $dest = $ENV{'form.newfilename'};
1.55 albertel 1160: } else {
1.47 sakharuk 1161: $r->print('<p>'.&mt('No New filename specified').'</p></form>');
1.12 foxr 1162: return;
1163: }
1164:
1.5 www 1165: } elsif ($ENV{'form.action'} eq 'newdir') {
1.38 www 1166: my $newdir= $ENV{'form.newfilename'};
1.12 foxr 1167: if(!&NewDir2($r, $uname, $newdir)) {
1168: return;
1169: }
1.55 albertel 1170: $dest = $newdir."/";
1.12 foxr 1171: }
1.51 raeburn 1172: if ( ($ENV{'form.action'} eq 'newdir') && ($ENV{'form.phase'} eq 'two') && ( ($ENV{'form.callingmode'} eq 'testbank') || ($ENV{'form.callingmode'} eq 'imsimport') ) ) {
1.55 albertel 1173: $r->print('<h3><a href="javascript:self.close()">'.&mt('Done').'</a></h3>');
1.51 raeburn 1174: } else {
1.55 albertel 1175: $r->print('<h3><a href="'.&url($dest).'">'.&mt('Done').'</a></h3>');
1.51 raeburn 1176: }
1.1 www 1177: }
1178:
1179: sub handler {
1180:
1.55 albertel 1181: $r=shift;
1.1 www 1182:
1.60 www 1183: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress','action','filename','newfilename']);
1.9 foxr 1184:
1.55 albertel 1185: &Debug($r, "loncfile.pm - handler entered");
1186: &Debug($r, " filename: ".$ENV{'form.filename'});
1187: &Debug($r, " newfilename: ".$ENV{'form.newfilename'});
1.36 www 1188: #
1189: # Determine the root filename
1190: # This could come in as "filename", which actually is a URL, or
1191: # as "qualifiedfilename", which is indeed a real filename in filesystem
1192: #
1.55 albertel 1193: my $fn;
1.1 www 1194:
1.55 albertel 1195: if ($ENV{'form.filename'}) {
1.44 taceyjo1 1196: &Debug($r, "test: $ENV{'form.filename'}");
1.55 albertel 1197: $fn=&Apache::lonnet::unescape($ENV{'form.filename'});
1198: $fn=&URLToPath($fn);
1199: } elsif($ENV{'QUERY_STRING'} && $ENV{'form.phase'} ne 'two') {
1200: #Just hijack the script only the first time around to inject the
1201: #correct information for further processing
1202: $fn=&Apache::lonnet::unescape($ENV{'form.decompress'});
1.44 taceyjo1 1203: $fn=&URLToPath($fn);
1204: $ENV{'form.action'}="decompress";
1.55 albertel 1205: } elsif ($ENV{'form.qualifiedfilename'}) {
1206: $fn=$ENV{'form.qualifiedfilename'};
1207: } else {
1208: &Debug($r, "loncfile::handler - no form.filename");
1209: $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
1210: ' unspecified filename for cfile', $r->filename);
1211: return HTTP_NOT_FOUND;
1212: }
1.44 taceyjo1 1213:
1.55 albertel 1214: unless ($fn) {
1215: &Debug($r, "loncfile::handler - doctored url is empty");
1216: $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
1217: ' trying to cfile non-existing file', $r->filename);
1218: return HTTP_NOT_FOUND;
1219: }
1.1 www 1220:
1221: # ----------------------------------------------------------- Start page output
1.55 albertel 1222: my $uname;
1223: my $udom;
1224:
1225: ($uname,$udom)=
1226: &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain'));
1227: &Debug($r,
1228: "loncfile::handler constructaccess uname = $uname domain = $udom");
1229: unless (($uname) && ($udom)) {
1230: $r->log_reason($uname.' at '.$udom.
1231: ' trying to manipulate file '.$ENV{'form.filename'}.
1232: ' ('.$fn.') - not authorized',
1233: $r->filename);
1234: return HTTP_NOT_ACCEPTABLE;
1235: }
1236:
1.1 www 1237:
1.55 albertel 1238: &Apache::loncommon::content_type($r,'text/html');
1239: $r->send_http_header;
1240:
1241: if ( ($ENV{'form.action'} eq 'newdir') && ($ENV{'form.phase'} eq 'two') && ( ($ENV{'form.callingmode'} eq 'testbank') || ($ENV{'form.callingmode'} eq 'imsimport') ) ) {
1242: my $newdirname = $ENV{'form.newfilename'};
1243: $r->print('<html><head><title>LON-CAPA Construction Space</title><script language="Javascript">');
1244: $r->print(qq|
1.51 raeburn 1245: function writeDone() {
1246: var winName = window.opener
1247: window.focus();
1248: winName.document.dataForm.newdir.value = "$newdirname"
1249: setTimeout("self.close()",10000)
1250: }
1251: </script>
1252: </head>|);
1.55 albertel 1253: my $loaditem = 'onLoad="writeDone()"';
1254: $r->print(&Apache::loncommon::bodytag('Construction Space File Operation','',$loaditem));
1255: } else {
1256: $r->print('<html><head><title>LON-CAPA Construction Space</title></head>');
1257: $r->print(&Apache::loncommon::bodytag('Construction Space File Operation'));
1258: }
1.1 www 1259:
1260:
1.55 albertel 1261: $r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>');
1.1 www 1262:
1.55 albertel 1263: if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
1264: $r->print('<h3><font color="red">'.&mt('Co-Author').': '.$uname.' at '.$udom.
1265: '</font></h3>');
1266: }
1267:
1268:
1269: &Debug($r, "loncfile::handler Form action is $ENV{'form.action'} ");
1270: if ($ENV{'form.action'} eq 'delete') {
1271: $r->print('<h3>'.&mt('Delete').'</h3>');
1272: } elsif ($ENV{'form.action'} eq 'rename') {
1273: $r->print('<h3>'.&mt('Rename').'</h3>');
1274: } elsif ($ENV{'form.action'} eq 'move') {
1275: $r->print('<h3>'.&mt('Move').'</h3>');
1276: } elsif ($ENV{'form.action'} eq 'newdir') {
1277: $r->print('<h3>'.&mt('New Directory').'</h3>');
1278: } elsif ($ENV{'form.action'} eq 'decompress') {
1279: $r->print('<h3>'.&mt('Decompress').'</h3>');
1280: } elsif ($ENV{'form.action'} eq 'copy') {
1281: $r->print('<h3>'.&mt('Copy').'</h3>');
1282: } elsif ($ENV{'form.action'} eq 'newfile' ||
1283: $ENV{'form.action'} eq 'newhtmlfile' ||
1284: $ENV{'form.action'} eq 'newproblemfile' ||
1285: $ENV{'form.action'} eq 'newpagefile' ||
1286: $ENV{'form.action'} eq 'newsequencefile' ||
1287: $ENV{'form.action'} eq 'newrightsfile' ||
1288: $ENV{'form.action'} eq 'newstyfile' ||
1289: $ENV{'form.action'} eq 'Select Action' ) {
1290: $r->print('<h3>'.&mt('New Resource').'</h3>');
1291: } else {
1292: $r->print('<p>'.&mt('Unknown Action').' '.$ENV{'form.action'}.' </p></body></html>');
1293: return OK;
1294: }
1295: if ($ENV{'form.phase'} eq 'two') {
1296: &Debug($r, "loncfile::handler entering phase2");
1297: &phasetwo($r,$fn,$uname,$udom);
1298: } else {
1299: &Debug($r, "loncfile::handler entering phase1");
1300: &phaseone($r,$fn,$uname,$udom);
1301: }
1.1 www 1302:
1.55 albertel 1303: $r->print('</body></html>');
1304: return OK;
1.1 www 1305: }
1306:
1307: 1;
1308: __END__
1.9 foxr 1309:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>