Parent Directory
|
Revision Log
modified use lib lines in cgi-scripts, scripts, courseScripts removed Global.pm updating and use lib line code from system_webwork_setup modified Global.pm to use webworkConfig (which is not in the repository!)
1 #!/usr/local/bin/webwork-perl 2 3 4 #################################################################### 5 # Copyright @ 1995-1998 University of Rochester 6 # All Rights Reserved 7 #################################################################### 8 9 ## profRemoveTmpFiles.pl 10 ## Remove tempory files from .../html/tmp/eps, .../html/tmp/gif 11 12 use lib '.'; use webworkInit; # WeBWorKInitLine 13 use CGI qw(:standard); 14 use Global; 15 use Auth; 16 use strict; 17 18 19 # begin Timing code 20 use Benchmark; 21 my $beginTime = new Benchmark; 22 # end Timing code 23 24 &CGI::ReadParse; 25 my %inputs =%main::in; 26 27 # get information from CGI inputs (see also below for additional information) 28 29 my $Course = $inputs{'course'}; 30 my $User = $inputs{'user'}; 31 my $Session_key = $inputs{'key'}; 32 33 34 # verify that information has been received 35 unless($Course && $User && $Session_key) { 36 &wwerror("$0","The script did not receive the proper input data.","",""); 37 } 38 39 40 # establish environment for this script 41 42 &Global::getCourseEnvironment($inputs{'course'}); 43 44 my $cgiURL = getWebworkCgiURL; 45 my $databaseDirectory = getCourseDatabaseDirectory($Course); 46 my $scriptDirectory = getWebworkScriptDirectory; 47 my $tmpDirectory = getCourseTempDirectory($Course); 48 49 50 require "${scriptDirectory}$Global::DBglue_pl"; 51 require "${scriptDirectory}$Global::FILE_pl"; 52 require "${scriptDirectory}$Global::HTMLglue_pl"; 53 require "${scriptDirectory}$Global::SCRtools_pl"; 54 55 # log access 56 &Global::log_info('', query_string); 57 58 59 my $permissionsFile = &Global::getCoursePermissionsFile($inputs{'course'}); 60 my $permissions = &get_permissions($inputs{'user'}, $permissionsFile); 61 my $keyFile = &Global::getCourseKeyFile($inputs{'course'}); 62 63 64 #verify session key 65 &verify_key($inputs{'user'}, $inputs{'key'}, $keyFile, $inputs{'course'}); 66 67 # verify permissions are correct 68 if ($permissions != $Global::instructor_permissions ) { 69 print "permissions = $permissions instructor_permissions = $Global::instructor_permissions\n"; 70 print &html_NO_PERMISSION; 71 exit(0); 72 } 73 74 ## clean up eps, html and gif directories. 75 76 my $epsDirectory = convertPath("${tmpDirectory}eps"); 77 cleanUpDirectory($epsDirectory); 78 my $gifDirectory = convertPath("${tmpDirectory}gif"); 79 cleanUpDirectory($gifDirectory); 80 my $hlDirectory = convertPath("${tmpDirectory}html"); 81 cleanUpDirectory($hlDirectory); 82 cleanUpDirectory($tmpDirectory); 83 cleanUpSuccess(); 84 exit; 85 86 87 ## subroutines 88 89 sub cleanUpDirectory { 90 my ($directory) = @_; 91 92 return 0 unless (-e $directory); 93 94 my ($file, $user, %active, $name); 95 96 ## We delete all files except 97 ## those associated with active users 98 99 my @activeUsers = (); 100 my @allfiles = (); 101 my @tmpArray = (); 102 my @toDeleteFiles = (); 103 104 opendir( DIRHANDLE, "$directory") or 105 wwerror($0,"Can't open directory $directory",'','',''); 106 @allfiles = grep( !/^\.\.?$/, readdir DIRHANDLE); 107 closedir(DIRHANDLE); 108 109 @activeUsers = get_active_users_from_keysDB($keyFile); 110 111 foreach $user (@activeUsers) {$active{$user} =1;} 112 113 foreach $file (@allfiles) { 114 $file =~ m!(^[^-\.]*)!; ##tmp files are named e.g. apizer-123245... 115 ## or apizer.123245... 116 $name = $1; 117 push @tmpArray, $file unless $active{$name}; 118 } 119 120 $directory = convertPath("$directory/"); ## add trailing / 121 @toDeleteFiles = map "$directory$_", @tmpArray; 122 123 unlink(@toDeleteFiles); 124 1; 125 } 126 127 128 129 130 sub cleanUpSuccess { 131 132 print"content-type:\n\n<H2>Success, tmp files removed. </H2>\n"; 133 print "The temporary eps, gif, and html files have been removed from 134 $epsDirectory, $gifDirectory and $hlDirectory. <BR>"; 135 print "Also temporary files have been removed from 136 $tmpDirectory."; 137 138 139 print "<FORM METHOD=POST ACTION=\"${cgiURL}profLogin.pl\"><P>"; 140 print &sessionKeyInputs(\%inputs); 141 print <<"ENDOFHTML"; 142 <INPUT TYPE=SUBMIT VALUE="Return to Prof Page"> 143 </FORM> 144 ENDOFHTML 145 print &htmlBOTTOM("profRemoveTmpFiles.pl", \%inputs); 146 } 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |