[LON-CAPA-cvs] cvs: loncom /auth lonacc.pm loncacc.pm publiccheck.pm /interface loncommon.pm lonerrorhandler.pm lonsupportreq.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 13 Apr 2006 19:07:33 -0000


This is a MIME encoded message

--albertel1144955253
Content-Type: text/plain

albertel		Thu Apr 13 15:07:33 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonerrorhandler.pm lonsupportreq.pm 
    /loncom/auth	lonacc.pm loncacc.pm publiccheck.pm 
  Log:
  - moving get_posted_cgi from loncommon to lonacc
  
  
--albertel1144955253
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060413150733.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.332 loncom/interface/loncommon.pm:1.333
--- loncom/interface/loncommon.pm:1.332	Thu Apr 13 15:01:25 2006
+++ loncom/interface/loncommon.pm	Thu Apr 13 15:07:11 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.332 2006/04/13 19:01:25 albertel Exp $
+# $Id: loncommon.pm,v 1.333 2006/04/13 19:07:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3673,92 +3673,6 @@
     return;
 }
 
-###############################################
-
-sub get_posted_cgi {
-    my $r=shift;
-
-    my $buffer;
-    if ($r->header_in('Content-length')) {
-	$r->read($buffer,$r->header_in('Content-length'),0);
-    }
-    unless ($buffer=~/^(\-+\w+)\s+Content\-Disposition\:\s*form\-data/si) {
-	my @pairs=split(/&/,$buffer);
-	my $pair;
-	foreach $pair (@pairs) {
-	    my ($name,$value) = split(/=/,$pair);
-	    $value =~ tr/+/ /;
-	    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
-	    $name  =~ tr/+/ /;
-	    $name  =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
-	    &add_to_env("form.$name",$value);
-	}
-    } else {
-	my $contentsep=$1;
-	my @lines = split (/\n/,$buffer);
-	my $name='';
-	my $value='';
-	my $fname='';
-	my $fmime='';
-	my $i;
-	for ($i=0;$i<=$#lines;$i++) {
-	    if ($lines[$i]=~/^$contentsep/) {
-		if ($name) {
-		    chomp($value);
-		    if ($fname) {
-			$env{"form.$name.filename"}=$fname;
-			$env{"form.$name.mimetype"}=$fmime;
-		    } else {
-			$value=~s/\s+$//s;
-		    }
-		    &add_to_env("form.$name",$value);
-		}
-		if ($i<$#lines) {
-		    $i++;
-		    $lines[$i]=~
-		/Content\-Disposition\:\s*form\-data\;\s*name\=\"([^\"]+)\"/i;
-		    $name=$1;
-		    $value='';
-		    if ($lines[$i]=~/filename\=\"([^\"]+)\"/i) {
-			$fname=$1;
-			if 
-                            ($lines[$i+1]=~/Content\-Type\:\s*([\w\-\/]+)/i) {
-				$fmime=$1;
-				$i++;
-			    } else {
-				$fmime='';
-			    }
-		    } else {
-			$fname='';
-			$fmime='';
-		    }
-		    $i++;
-		}
-	    } else {
-		$value.=$lines[$i]."\n";
-	    }
-	}
-    }
-#
-# Digested POSTed values
-#
-# Remember the way this was originally done (GET or POST)
-#
-    $env{'request.method'}=$ENV{'REQUEST_METHOD'};
-#
-# There may also be stuff in the query string
-# Tell subsequent handlers that this was GET, not POST, so they can access query string.
-# Also, unset POSTed content length to cover all tracks.
-#
-
-# This does not work, because M_GET is not defined (if it's defined, it is just 0). 
-# Commenting out for now ... not sure if harm is done.
-#    $r->method_number(M_GET);
-
-    $r->method('GET');
-    $r->headers_in->unset('Content-length');
-}
-
 =pod
 
 =item * get_unprocessed_cgi($query,$possible_names)
Index: loncom/interface/lonerrorhandler.pm
diff -u loncom/interface/lonerrorhandler.pm:1.10 loncom/interface/lonerrorhandler.pm:1.11
--- loncom/interface/lonerrorhandler.pm:1.10	Tue Mar 21 13:33:39 2006
+++ loncom/interface/lonerrorhandler.pm	Thu Apr 13 15:07:11 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Internal Server Error Handler
 #
-# $Id: lonerrorhandler.pm,v 1.10 2006/03/21 18:33:39 albertel Exp $
+# $Id: lonerrorhandler.pm,v 1.11 2006/04/13 19:07:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,9 +30,10 @@
 
 use strict;
 use Apache::Constants qw(:common);
-use Apache::loncommon;
+use Apache::loncommon();
 use Apache::lonnet;
-use Apache::lonmsg;
+use Apache::lonmsg();
+use Apache::lonacc();
 
 sub handler {
     my $r = shift;
@@ -40,7 +41,7 @@
     $r->send_http_header;
     return OK if $r->header_only;
 
-    &Apache::loncommon::get_posted_cgi($r);
+    &Apache::lonacc::get_posted_cgi($r);
 
     my $title = $env{'form.sendinfo'} ? 'Sending Error Report'
                                       : 'Could Not Process Request';
Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.33 loncom/interface/lonsupportreq.pm:1.34
--- loncom/interface/lonsupportreq.pm:1.33	Mon Apr 10 17:40:09 2006
+++ loncom/interface/lonsupportreq.pm	Thu Apr 13 15:07:11 2006
@@ -1,5 +1,5 @@
 #
-# $Id: lonsupportreq.pm,v 1.33 2006/04/10 21:40:09 albertel Exp $
+# $Id: lonsupportreq.pm,v 1.34 2006/04/13 19:07:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,6 +35,7 @@
 use Apache::loncommon();
 use Apache::lonnet;
 use Apache::lonlocal;
+use Apache::lonacc();
 
 sub handler {
     my ($r) = @_;
@@ -46,7 +47,7 @@
     }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['origurl','function']);
     if ($r->uri eq '/adm/helpdesk') {
-        &Apache::loncommon::get_posted_cgi($r);
+        &Apache::lonacc::get_posted_cgi($r);
     }
     my $function = $env{'form.function'};
     my $origurl = &Apache::lonnet::unescape($env{'form.origurl'});
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.75 loncom/auth/lonacc.pm:1.76
--- loncom/auth/lonacc.pm:1.75	Fri Apr  7 18:42:00 2006
+++ loncom/auth/lonacc.pm	Thu Apr 13 15:07:33 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: lonacc.pm,v 1.75 2006/04/07 22:42:00 albertel Exp $
+# $Id: lonacc.pm,v 1.76 2006/04/13 19:07:33 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -51,6 +51,91 @@
     return DONE;
 }
 
+###############################################
+
+sub get_posted_cgi {
+    my ($r) = @_;
+
+    my $buffer;
+    if ($r->header_in('Content-length')) {
+	$r->read($buffer,$r->header_in('Content-length'),0);
+    }
+    unless ($buffer=~/^(\-+\w+)\s+Content\-Disposition\:\s*form\-data/si) {
+	my @pairs=split(/&/,$buffer);
+	my $pair;
+	foreach $pair (@pairs) {
+	    my ($name,$value) = split(/=/,$pair);
+	    $value =~ tr/+/ /;
+	    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
+	    $name  =~ tr/+/ /;
+	    $name  =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
+	    &add_to_env("form.$name",$value);
+	}
+    } else {
+	my $contentsep=$1;
+	my @lines = split (/\n/,$buffer);
+	my $name='';
+	my $value='';
+	my $fname='';
+	my $fmime='';
+	my $i;
+	for ($i=0;$i<=$#lines;$i++) {
+	    if ($lines[$i]=~/^$contentsep/) {
+		if ($name) {
+		    chomp($value);
+		    if ($fname) {
+			$env{"form.$name.filename"}=$fname;
+			$env{"form.$name.mimetype"}=$fmime;
+		    } else {
+			$value=~s/\s+$//s;
+		    }
+		    &add_to_env("form.$name",$value);
+		}
+		if ($i<$#lines) {
+		    $i++;
+		    $lines[$i]=~
+		/Content\-Disposition\:\s*form\-data\;\s*name\=\"([^\"]+)\"/i;
+		    $name=$1;
+		    $value='';
+		    if ($lines[$i]=~/filename\=\"([^\"]+)\"/i) {
+			$fname=$1;
+			if 
+                            ($lines[$i+1]=~/Content\-Type\:\s*([\w\-\/]+)/i) {
+				$fmime=$1;
+				$i++;
+			    } else {
+				$fmime='';
+			    }
+		    } else {
+			$fname='';
+			$fmime='';
+		    }
+		    $i++;
+		}
+	    } else {
+		$value.=$lines[$i]."\n";
+	    }
+	}
+    }
+#
+# Digested POSTed values
+#
+# Remember the way this was originally done (GET or POST)
+#
+    $env{'request.method'}=$ENV{'REQUEST_METHOD'};
+#
+# There may also be stuff in the query string
+# Tell subsequent handlers that this was GET, not POST, so they can access query string.
+# Also, unset POSTed content length to cover all tracks.
+#
+
+    $r->method_number(M_GET);
+
+    $r->method('GET');
+    $r->headers_in->unset('Content-length');
+}
+
+
 sub handler {
     my $r = shift;
     my $requrl=$r->uri;
@@ -103,7 +188,7 @@
             $env{'request.noversionuri'} = &Apache::lonnet::deversion($requrl);
 # -------------------------------------------------------- Load POST parameters
 
-	    &Apache::loncommon::get_posted_cgi($r);
+	    &Apache::lonacc::get_posted_cgi($r);
 
 # ---------------------------------------------------------------- Check access
 
@@ -208,7 +293,7 @@
 	    &Apache::lonauth::success($r,'public','public','public');
         my $lonidsdir=$r->dir_config('lonIDsDir');
 	&Apache::lonnet::transfer_profile_to_env($lonidsdir,$cookie);
-	&Apache::loncommon::get_posted_cgi($r);
+	&Apache::lonacc::get_posted_cgi($r);
         $env{'request.state'} = "published";
         $env{'request.publicaccess'} = 1;
         $env{'request.filename'} = $r->filename;
Index: loncom/auth/loncacc.pm
diff -u loncom/auth/loncacc.pm:1.40 loncom/auth/loncacc.pm:1.41
--- loncom/auth/loncacc.pm:1.40	Tue Jul 12 03:00:28 2005
+++ loncom/auth/loncacc.pm	Thu Apr 13 15:07:33 2006
@@ -2,7 +2,7 @@
 # Cookie Based Access Handler for Construction Area
 # (lonacc: 5/21/99,5/22,5/29,5/31 Gerd Kortemeyer)
 #
-# $Id: loncacc.pm,v 1.40 2005/07/12 07:00:28 albertel Exp $
+# $Id: loncacc.pm,v 1.41 2006/04/13 19:07:33 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,12 +31,11 @@
 
 use strict;
 use Apache::Constants qw(:common :http :methods REDIRECT);
-use Apache::File;
 use CGI::Cookie();
 use Fcntl qw(:flock);
 use Apache::lonlocal;
 use Apache::lonnet;
-
+use Apache::lonacc;
 
 sub constructaccess {
     my ($url,$ownerdomain)=@_;
@@ -95,7 +94,7 @@
 
 # -------------------------------------------------------- Load POST parameters
 
-	    &Apache::loncommon::get_posted_cgi($r);
+	    &Apache::lonacc::get_posted_cgi($r);
 
             return OK; 
         } else { 
Index: loncom/auth/publiccheck.pm
diff -u loncom/auth/publiccheck.pm:1.1 loncom/auth/publiccheck.pm:1.2
--- loncom/auth/publiccheck.pm:1.1	Wed Apr  5 18:34:18 2006
+++ loncom/auth/publiccheck.pm	Thu Apr 13 15:07:33 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: publiccheck.pm,v 1.1 2006/04/05 22:34:18 albertel Exp $
+# $Id: publiccheck.pm,v 1.2 2006/04/13 19:07:33 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,12 +31,12 @@
 
 use strict;
 use Apache::Constants qw(:common :http :methods);
-use Apache::File;
 use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonlocal;
 use CGI::Cookie();
 use Fcntl qw(:flock);
+use Apache::lonacc();
 
 sub handler {
     my $r = shift;
@@ -66,7 +66,7 @@
 	    &Apache::lonnet::transfer_profile_to_env($lonidsdir,$cookie);
 	    $r->header_out('Set-cookie',"lonID=$cookie; path=/");
 	}
-	&Apache::loncommon::get_posted_cgi($r);
+	&Apache::lonacc::get_posted_cgi($r);
         $env{'request.state'} = "published";
         $env{'request.publicaccess'} = 1;
         $env{'request.filename'} = $r->filename;

--albertel1144955253--