--- loncom/homework/randomlylabel.pm	2006/05/30 12:45:37	1.28
+++ loncom/homework/randomlylabel.pm	2007/09/25 22:56:48	1.29
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # randomlabel.png: composite together text and images into 1 image
 #
-# $Id: randomlylabel.pm,v 1.28 2006/05/30 12:45:37 www Exp $
+# $Id: randomlylabel.pm,v 1.29 2007/09/25 22:56:48 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -271,20 +271,24 @@ sub handler {
     my $r = shift;
     $r->content_type('image/png');
     $r->send_http_header;
-    my (undef,$id) = split(/=/,$ENV{'QUERY_STRING'});
-    my $image;
-    my $prefix="cgi.$id.";
+
+    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
+
+    my $prefix;
     if ($ENV{'QUERY_STRING'}=~/OBJCOUNT\=/) {
-	&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
 	$prefix='form.';
+    } else {
+	$prefix="cgi.$env{'form.token'}.";
     }
+
+    my $image;
     if (defined($env{$prefix."BGIMG"})) {
 	my $bgimg=&unescape($env{$prefix."BGIMG"});
 	#&Apache::lonnet::logthis("BGIMG is ".$bgimg);
 	$image=&get_image($bgimg,0);
 	if (! defined($image)) {
 	    &Apache::lonnet::logthis('Unable to create image object for -'.
-				     $id.'-'.$bgimg);
+				     $env{'form.token'}.'-'.$bgimg);
 	    return OK;
 	}
     } elsif (defined($env{$prefix."SIZE"})) {
@@ -301,7 +305,7 @@ sub handler {
 	    $image->transparent($bgcolor);
 	}
     } else {
-	&Apache::lonnet::logthis('Unable to create image object, no info');
+	&Apache::lonnet::logthis('Unable to create image object, no info '.$prefix);
 	return OK;
     }
     #binmode(STDOUT);