Index: loncom/automation/batchcreatecourse.pm diff -u loncom/automation/batchcreatecourse.pm:1.36 loncom/automation/batchcreatecourse.pm:1.37 --- loncom/automation/batchcreatecourse.pm:1.36 Mon May 24 06:32:38 2010 +++ loncom/automation/batchcreatecourse.pm Mon Jul 4 09:24:46 2011 @@ -1,5 +1,5 @@ # -# $Id: batchcreatecourse.pm,v 1.36 2010/05/24 06:32:38 raeburn Exp $ +# $Id: batchcreatecourse.pm,v 1.37 2011/07/04 09:24:46 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -205,7 +205,7 @@ } my ($logmsg,$keysmsg,$newusermsg,$addresult); my %enrollcount = (); - my $newcoursedir = $$perlvarref{'lonDaemons'}.'/tmp/addcourse/'.$dom.'/'.$context; + my $newcoursedir = LONCAPA::tempdir().'/addcourse/'.$dom.'/'.$context; if ($context eq 'auto') { $newcoursedir .= '/pending'; } else { Index: loncom/debugging_tools/getties.pl diff -u loncom/debugging_tools/getties.pl:1.1 loncom/debugging_tools/getties.pl:1.2 --- loncom/debugging_tools/getties.pl:1.1 Thu Jun 12 21:00:19 2003 +++ loncom/debugging_tools/getties.pl Mon Jul 4 09:24:50 2011 @@ -1,5 +1,14 @@ +# +# as this is a standalong file..that may ot be able to access the LONCAPA +# module, I'm leaving the temp directory knoweldge uncentralized +# - R. Fox 7/1/2011 +# + use strict; -my $result=`ls -l /proc/*/fd/* | grep /home/httpd/perl/tmp/`; + +my $loncapa_tempdir = '/home/httpd/perl/tmp'; # configure the temp dir here. + +my $result=`ls -l /proc/*/fd/* | grep $loncapa_tempdir`; my @result=split("\n",$result); my (@pids,@files); foreach my $line (@result) { Index: loncom/homework/chemresponse.pm diff -u loncom/homework/chemresponse.pm:1.88 loncom/homework/chemresponse.pm:1.89 --- loncom/homework/chemresponse.pm:1.88 Mon Oct 4 14:34:43 2010 +++ loncom/homework/chemresponse.pm Mon Jul 4 09:24:54 2011 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # chemical equation style response # -# $Id: chemresponse.pm,v 1.88 2010/10/04 14:34:43 www Exp $ +# $Id: chemresponse.pm,v 1.89 2011/07/04 09:24:54 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -417,7 +417,8 @@ $id=&escape($id); &Apache::lonxml::register_ssi("/cgi-bin/convertjme.pl?$id"); if ($options =~ /border/) { $result.= '\fbox{'; } - $result .= '\graphicspath{{/home/httpd/perl/tmp/}}\includegraphics[width='.$texwidth.' mm]{'.$filename.'.eps}'; + $result .= '\graphicspath{{'.LONCAPA::tempdir(). + '}}\includegraphics[width='.$texwidth.' mm]{'.$filename.'.eps}'; if ($options =~ /border/) { $result.= '} '; } } elsif ($target eq 'edit') { $result .=&Apache::edit::tag_start($target,$token); Index: loncom/homework/convertjme.pl diff -u loncom/homework/convertjme.pl:1.15 loncom/homework/convertjme.pl:1.16 --- loncom/homework/convertjme.pl:1.15 Wed May 25 22:31:51 2005 +++ loncom/homework/convertjme.pl Mon Jul 4 09:24:54 2011 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Dynamically converts JME strings into either a png or ps file. # -# $Id: convertjme.pl,v 1.15 2005/05/25 22:31:51 albertel Exp $ +# $Id: convertjme.pl,v 1.16 2011/07/04 09:24:54 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,7 +35,7 @@ my $loncapa=1; use lib '/home/httpd/lib/perl'; use LONCAPA::loncgi; - +use LONCAPA; use GD; use PostScript::Simple; @@ -431,7 +431,7 @@ print "Content-type: image/png\n\n"; print $im->png; } elsif ($ps) { - my $psfile = "/home/httpd/perl/tmp/".$id.'.eps'; + my $psfile = LONCAPA::tempdir().$id.'.eps'; $im->output($psfile); print "Content-type: text/html\n\n"; print (<set_tempdir('/home/httpd/perl/tmp'); + $workbook->set_tempdir(LONCAPA::tempdir()); # my $format = &Apache::loncommon::define_excel_formats($workbook); return ($workbook,$filename,$format); Index: loncom/interface/lonindexer.pm diff -u loncom/interface/lonindexer.pm:1.208 loncom/interface/lonindexer.pm:1.209 --- loncom/interface/lonindexer.pm:1.208 Fri Aug 13 13:32:36 2010 +++ loncom/interface/lonindexer.pm Mon Jul 4 09:24:58 2011 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.208 2010/08/13 13:32:36 wenzelju Exp $ +# $Id: lonindexer.pm,v 1.209 2011/07/04 09:24:58 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -120,8 +120,8 @@ my $colspan=''; $extrafield=''; - my $diropendb = - "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_sel_res.db"; + my $diropendb = LONCAPA::tempdir() . + "$env{'user.domain'}_$env{'user.name'}_sel_res.db"; %hash = (); { my %dbfile; Index: loncom/interface/lonsearchcat.pm diff -u loncom/interface/lonsearchcat.pm:1.329 loncom/interface/lonsearchcat.pm:1.330 --- loncom/interface/lonsearchcat.pm:1.329 Tue Feb 15 14:54:51 2011 +++ loncom/interface/lonsearchcat.pm Mon Jul 4 09:24:58 2011 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.329 2011/02/15 14:54:51 wenzelju Exp $ +# $Id: lonsearchcat.pm,v 1.330 2011/07/04 09:24:58 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -152,7 +152,8 @@ ## Initialize global variables ## my $domain = $r->dir_config('lonDefDomain'); - $diropendb= "/home/httpd/perl/tmp/". + my $temp_file_dir = LONCAPA::tempdir(); + $diropendb= $temp_file_dir . "$env{'user.domain'}_$env{'user.name'}_sel_res.db"; # # set the name of the persistent database @@ -163,7 +164,7 @@ $env{'form.persistent_db_id'} = time; } - my $persistent_db_file = "/home/httpd/perl/tmp/". + my $persistent_db_file = $temp_file_dir . &escape($domain). '_'.&escape($env{'user.name'}). '_'.$env{'form.persistent_db_id'}.'_persistent_search.db'; @@ -2383,7 +2384,10 @@ next; } $status=~s|/||g; - my $datafile=$r->dir_config('lonDaemons').'/tmp/'.$status; + + + + my $datafile=LONCAPA::tempdir().$status; if (-e $datafile && ! -e "$datafile.end") { &update_status($r,&mt('Receiving results from [_1]',$server)); next; Index: loncom/interface/statistics/lonstathelpers.pm diff -u loncom/interface/statistics/lonstathelpers.pm:1.66 loncom/interface/statistics/lonstathelpers.pm:1.67 --- loncom/interface/statistics/lonstathelpers.pm:1.66 Fri Mar 25 01:34:53 2011 +++ loncom/interface/statistics/lonstathelpers.pm Mon Jul 4 09:25:02 2011 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstathelpers.pm,v 1.66 2011/03/25 01:34:53 www Exp $ +# $Id: lonstathelpers.pm,v 1.67 2011/07/04 09:25:02 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1004,7 +1004,7 @@ sub ensure_proper_cache { my ($symb) = @_; my $cid = $env{'request.course.id'}; - my $new_filename = '/home/httpd/perl/tmp/'. + my $new_filename = LONCAPA::tempdir() . 'problemanalysis_'.$cid.'_analysis_cache.db'; if (! defined($cache_filename) || $cache_filename ne $new_filename || Index: loncom/lonnet/perl/lonnet.pm diff -u loncom/lonnet/perl/lonnet.pm:1.1116 loncom/lonnet/perl/lonnet.pm:1.1117 --- loncom/lonnet/perl/lonnet.pm:1.1116 Mon Jun 13 17:41:04 2011 +++ loncom/lonnet/perl/lonnet.pm Mon Jul 4 09:25:06 2011 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1116 2011/06/13 17:41:04 raeburn Exp $ +# $Id: lonnet.pm,v 1.1117 2011/07/04 09:25:06 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -95,6 +95,7 @@ use File::MMagic; use LONCAPA qw(:DEFAULT :match); use LONCAPA::Configuration; + use File::Copy; my $readit; @@ -2573,7 +2574,7 @@ return '/adm/notfound.html'; } if ($context eq 'overwrite') { - my $source = $perlvar{'lonDaemons'}.'/tmp/overwrites/'.$docudom.'/'.$docuname.'/'.$fname; + my $source = LONCAPA::tempdir().'/overwrites/'.$docudom.'/'.$docuname.'/'.$fname; my $target = $filepath.'/'.$file; if (-e $source) { my @info = stat($source); @@ -3775,7 +3776,7 @@ if ($domain eq 'public' && $stuname eq 'public') { $stuname=$ENV{'REMOTE_ADDR'}; } - my $path=$perlvar{'lonDaemons'}.'/tmp'; + my $path=LONCAPA::tempdir(); my %hash; if (tie(%hash,'GDBM_File', $path.'/tmpstore_'.$stuname.'_'.$domain.'_'.$namespace.'.db', @@ -3814,7 +3815,7 @@ } my $now=time; my %hash; - my $path=$perlvar{'lonDaemons'}.'/tmp'; + my $path=LONCAPA::tempdir(); if (tie(%hash,'GDBM_File', $path.'/tmpstore_'.$stuname.'_'.$domain.'_'.$namespace.'.db', &GDBM_WRCREAT(),0640)) { @@ -3860,7 +3861,7 @@ $namespace=~s/\//\_/g; $namespace=~s/\W//g; my %hash; - my $path=$perlvar{'lonDaemons'}.'/tmp'; + my $path=LONCAPA::tempdir(); if (tie(%hash,'GDBM_File', $path.'/tmpstore_'.$stuname.'_'.$domain.'_'.$namespace.'.db', &GDBM_READER(),0640)) { @@ -4044,7 +4045,7 @@ $envhash{'course.'.$normalid.'.'.$name}=$value; } $returnhash{'url'}=&clutter($returnhash{'url'}); - $returnhash{'fn'}=$perlvar{'lonDaemons'}.'/tmp/'. + $returnhash{'fn'}=LONCAPA::tempdir() . $env{'user.name'}.'_'.$cdomain.'_'.$cnum; $envhash{'course.'.$normalid.'.home'}=$chome; $envhash{'course.'.$normalid.'.domain'}=$cdomain; @@ -5995,7 +5996,7 @@ $$replyref{$key} = $value; } } else { - my $pathname = $perlvar{'lonDaemons'}.'/tmp'; + my $pathname = LONCAPA::tempdir(); foreach my $line (@responses) { my ($key,$value) = split(/=/,$line); $$replyref{$key} = $value; @@ -6025,7 +6026,7 @@ sub get_query_reply { my $queryid=shift; - my $replyfile=$perlvar{'lonDaemons'}.'/tmp/'.$queryid; + my $replyfile=LONCAPA::tempdir().$queryid; my $reply=''; for (1..100) { sleep 2; @@ -7462,7 +7463,7 @@ sub clear_selected_files { my ($user) = @_; my $filename = $user."savedfiles"; - open (OUT, '>'.$Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/'.$filename); + open (OUT, '>'.LONCAPA::tempdir().$filename); print (OUT undef); close (OUT); return ("ok"); @@ -7472,7 +7473,7 @@ my ($user, $path) = @_; my $filename = $user."savedfiles"; my %return_files; - open (IN, '<'.$Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/'.$filename); + open (IN, '<'.LONCAPA::tempdir().$filename); while (my $line_in = ) { chomp ($line_in); my @paths_and_file = split (m!/!, $line_in); @@ -7494,7 +7495,7 @@ my $filename = $user."savedfiles"; my @return_files; my $path_part; - open(IN, '<'.$Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/'.$filename); + open(IN, '<'.LONCAPA::.$filename); while (my $line = ) { #ok, I know it's clunky, but I want it to work my @paths_and_file = split(m|/|, $line); @@ -9788,7 +9789,7 @@ my @ids=¤t_machine_ids(); foreach my $id (@ids) { if ($id eq $home) { $is_me=1; } } if ($is_me) { - $location=&propath($udom,$uname).'/userfiles/'.$filename; + $location=propath($udom,$uname).'/userfiles/'.$filename; } else { $location=$Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles/'. $udom.'/'.$uname.'/'.$filename; @@ -10543,7 +10544,7 @@ # ------------- set up temporary directory { - $tmpdir = $perlvar{'lonDaemons'}.'/tmp/'; + $tmpdir = LONCAPA::tempdir(); } Index: loncom/misc/archive_old_files.pl diff -u loncom/misc/archive_old_files.pl:1.3 loncom/misc/archive_old_files.pl:1.4 --- loncom/misc/archive_old_files.pl:1.3 Thu May 18 02:17:30 2006 +++ loncom/misc/archive_old_files.pl Mon Jul 4 09:25:10 2011 @@ -2,7 +2,7 @@ # The LearningOnline Network # zip all .db and .hist files that have not been accessed in 120 days # -# $Id: archive_old_files.pl,v 1.3 2006/05/18 02:17:30 www Exp $ +# $Id: archive_old_files.pl,v 1.4 2011/07/04 09:25:10 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,7 +29,17 @@ ################################################# use Fcntl qw(:flock); -my $oldfile="/home/httpd/perl/tmp/old_files.lst"; +# +# Since this is a standalone script that may not have access to the +# LONCAPA module, it is going to be exempt form the 'tmp' dir centralization +# effort. + +# This variable may require editing if you are not using standard loncapa +# directory configurations: + +my $tempdir = '/home/httpd/perl/tmp' + +my $oldfile = $tempdir."/old_files.lst"; system ("find /home/httpd/lonUsers/ -name *.db -atime +120 > $oldfile"); open(IN,$oldfile); Index: loncom/xml/lonplot.pm diff -u loncom/xml/lonplot.pm:1.152 loncom/xml/lonplot.pm:1.153 --- loncom/xml/lonplot.pm:1.152 Sat Nov 14 19:13:36 2009 +++ loncom/xml/lonplot.pm Mon Jul 4 09:25:13 2011 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Dynamic plot # -# $Id: lonplot.pm,v 1.152 2009/11/14 19:13:36 faziophi Exp $ +# $Id: lonplot.pm,v 1.153 2011/07/04 09:25:13 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -634,6 +634,8 @@ ('title','xlabel','ylabel','key','axis','label','curve')); my $result = ''; my $randnumber; + my $tmpdir =LONCAPA::tempdir(); # Where temporary files live: + # need to call rand everytime start_script would evaluate, as the # safe space rand number generator and the global rand generator # are not separate @@ -645,7 +647,6 @@ &check_inputs(); # Make sure we have all the data we need ## ## Determine filename - my $tmpdir = '/home/httpd/perl/tmp/'; my $filename = $env{'user.name'}.'_'.$env{'user.domain'}. '_'.time.'_'.$$.$randnumber.'_plot'; ## Write the plot description to the file @@ -666,7 +667,7 @@ #might be inside the safe space, register the URL for later &Apache::lonxml::register_ssi("/cgi-bin/plot.gif?file=$filename.data&output=eps"); $result = "%DYNAMICIMAGE:$Apache::lonplot::plot{'width'}:$Apache::lonplot::plot{'height'}:$Apache::lonplot::plot{'texwidth'}\n"; - $result .= '\graphicspath{{/home/httpd/perl/tmp/}}'."\n"; + $result .= '\graphicspath{{'.$tmpdir.'}}'."\n"; $result .= '\includegraphics[width='.$Apache::lonplot::plot{'texwidth'}.' mm]{'.&unescape($filename).'.eps}'; } } elsif ($target eq 'edit') { @@ -1609,7 +1610,7 @@ } $gnuplot_input .= ' "'.$font_properties->{'printname'}.'" '; $gnuplot_input .= $fontsize; - $gnuplot_input .= "\nset output \"/home/httpd/perl/tmp/". + $gnuplot_input .= "\nset output \"".$tmpdir. &unescape($filename).".eps\"\n"; $gnuplot_input .= "set encoding iso_8859_1\n"; # Get access to extended font. Index: rat/lonsequence.pm diff -u rat/lonsequence.pm:1.40 rat/lonsequence.pm:1.41 --- rat/lonsequence.pm:1.40 Tue Feb 23 05:00:16 2010 +++ rat/lonsequence.pm Mon Jul 4 09:25:17 2011 @@ -2,7 +2,7 @@ # # Sequence Handler # -# $Id: lonsequence.pm,v 1.40 2010/02/23 05:00:16 raeburn Exp $ +# $Id: lonsequence.pm,v 1.41 2011/07/04 09:25:17 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,7 @@ use Apache::Constants qw(:common :http REDIRECT); use GDBM_File; use LONCAPA::map(); +use LONCAPA; use Apache::lonpageflip(); use Apache::loncommon(); use Apache::groupsort(); @@ -109,7 +110,8 @@ ENDSELECT my $diropendb = - "/home/httpd/perl/tmp/$env{'user.domain'}\_$env{'user.name'}_sel_res.db"; + LONCAPA::tempdir() . + "$env{'user.domain'}\_$env{'user.name'}_sel_res.db"; if (tie(%selhash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { if ($env{'form.launch'} eq '1') { &start_fresh_session();