File:  [LON-CAPA] / loncom / publisher / loncfile.pm
Revision 1.57: download - view: text, annotated - select for diffs
Thu Jun 10 18:20:16 2004 UTC (20 years ago) by albertel
Branches: MAIN
CVS tags: HEAD
- " causes alot of things to go breaky. (BUG#3067 at least)

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>