[system] / trunk / webwork / system / cgi / cgi-scripts / profHousekeeping.pl Repository:
ViewVC logotype

Diff of /trunk/webwork/system/cgi/cgi-scripts/profHousekeeping.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 850 Revision 851
1#!/usr/bin/perl 1#!/usr/local/bin/webwork-perl
2 2
3 3
4## This file is profHousekeeping.pl 4## This file is profHousekeeping.pl
5## It provides access to utilities deleting uneeded files, etc. 5## It provides access to utilities deleting uneeded files, etc.
6## 6##
47my $databaseDirectory = getCourseDatabaseDirectory; 47my $databaseDirectory = getCourseDatabaseDirectory;
48my $htmlURL = getCourseHtmlURL; 48my $htmlURL = getCourseHtmlURL;
49my $scriptDirectory = getWebworkScriptDirectory; 49my $scriptDirectory = getWebworkScriptDirectory;
50my $htmlDirectory = getCourseHtmlDirectory; 50my $htmlDirectory = getCourseHtmlDirectory;
51my $templateDirectory = getCourseTemplateDirectory; 51my $templateDirectory = getCourseTemplateDirectory;
52my $dat = getDat; 52my $dat = getDat;
53 53
54require "${scriptDirectory}$Global::DBglue_pl"; 54require "${scriptDirectory}$Global::DBglue_pl";
55require "${scriptDirectory}$Global::FILE_pl"; 55require "${scriptDirectory}$Global::FILE_pl";
56require "${scriptDirectory}$Global::HTMLglue_pl"; 56require "${scriptDirectory}$Global::HTMLglue_pl";
57 57
63 my $permissions = &get_permissions($User, $permissionsFile); 63 my $permissions = &get_permissions($User, $permissionsFile);
64 my $keyFile = &Global::getCourseKeyFile($Course); 64 my $keyFile = &Global::getCourseKeyFile($Course);
65 65
66#verify session key 66#verify session key
67 &verify_key($User, $Session_key, $keyFile, $Course); 67 &verify_key($User, $Session_key, $keyFile, $Course);
68 68
69# verify permissions are correct 69# verify permissions are correct
70 if ($permissions != $Global::instructor_permissions ) { 70 if ($permissions != $Global::instructor_permissions ) {
71 print "permissions = $permissions instructor_permissions = $Global::instructor_permissions\n"; 71 print "permissions = $permissions instructor_permissions = $Global::instructor_permissions\n";
72 print &html_NO_PERMISSION; 72 print &html_NO_PERMISSION;
73 exit(0); 73 exit(0);
95 "\n\n", $cgi->h3({ -align=>'left' }, "WeBWorK Housekeeping Utilities for $Course"), "\n", 95 "\n\n", $cgi->h3({ -align=>'left' }, "WeBWorK Housekeeping Utilities for $Course"), "\n",
96 $cgi->p, 96 $cgi->p,
97 "From this page, you can recover disk space by removing old tmp files, 97 "From this page, you can recover disk space by removing old tmp files,
98 compress the gdbm database, show active users, edit the Course Environment file, etc."; 98 compress the gdbm database, show active users, edit the Course Environment file, etc.";
99 99
100# remove tmp files 100# remove tmp files
101print heading('Cleanup', "1. Cleanup $Course:"), 101print heading('Cleanup', "1. Cleanup $Course:"),
102 $cgi->startform(-action=>"${cgiURL}profRemoveTmpFiles.pl"), 102 $cgi->startform(-action=>"${cgiURL}profRemoveTmpFiles.pl"),
103 $cgi->submit(-value=>'Remove unnecessary tmp files'), "\n", 103 $cgi->submit(-value=>'Remove unnecessary tmp files'), "\n",
104 hiddens('user', 'key', 'course'), 104 hiddens('user', 'key', 'course'),
105 $cgi->endform(), "\n", 105 $cgi->endform(), "\n",
119 $cgi->startform(-action=>"${cgiURL}profShowActiveUsers.pl"), 119 $cgi->startform(-action=>"${cgiURL}profShowActiveUsers.pl"),
120 $cgi->submit(-value=>'Show Active Users'), "\n", 120 $cgi->submit(-value=>'Show Active Users'), "\n",
121 hiddens('user', 'key', 'course'), 121 hiddens('user', 'key', 'course'),
122 $cgi->endform(), "\n", 122 $cgi->endform(), "\n",
123 $cgi->p, "This lists all users who are currently logged into $Course."; 123 $cgi->p, "This lists all users who are currently logged into $Course.";
124 124
125# templates/motd.txt 125# templates/motd.txt
126my $filename = "${templateDirectory}motd.txt"; 126my $filename = "${templateDirectory}motd.txt";
127my ($date, $label, @stat); 127my ($date, $label, @stat);
128 128
129if (-e $filename) { 129if (-e $filename) {
139 $cgi->submit(-value=>'Edit Course motd.txt File'), "$label\n", 139 $cgi->submit(-value=>'Edit Course motd.txt File'), "$label\n",
140 hiddens('user', 'key', 'course'), 140 hiddens('user', 'key', 'course'),
141 $cgi->hidden(-name=>'filename', -value=>"motd.txt"), "\n", 141 $cgi->hidden(-name=>'filename', -value=>"motd.txt"), "\n",
142 $cgi->hidden(-name=>'ext', -value=>'txt'), "\n", 142 $cgi->hidden(-name=>'ext', -value=>'txt'), "\n",
143 $cgi->endform(), "\n", 143 $cgi->endform(), "\n",
144 $cgi->p, "This lets you edit the Course motd.txt File for $Course."; 144 $cgi->p, "This lets you edit the Course motd.txt File for $Course.";
145 145
146# webworkcourse.ph 146# webworkcourse.ph
147$filename = "${courseDirectory}$Global::courseEnvironmentFile"; 147$filename = "${courseDirectory}$Global::courseEnvironmentFile";
148#($date, $label, @stat); 148#($date, $label, @stat);
149if (-e $filename) { 149if (-e $filename) {
181 hiddens('user', 'key', 'course'), 181 hiddens('user', 'key', 'course'),
182 $cgi->hidden(-name=>'filename', -value=>"index.html"), "\n", 182 $cgi->hidden(-name=>'filename', -value=>"index.html"), "\n",
183 $cgi->hidden(-name=>'ext', -value=>'html'), "\n", 183 $cgi->hidden(-name=>'ext', -value=>'html'), "\n",
184 $cgi->endform(), "\n", 184 $cgi->endform(), "\n",
185 $cgi->p, "This lets you edit the Course index.html File for $Course."; 185 $cgi->p, "This lets you edit the Course index.html File for $Course.";
186 186
187print heading('dataMungerPSVN', "7. Cange data for a PSVN in $Course:"), 187print heading('dataMungerPSVN', "7. Change data for a PSVN in $Course:"),
188 $cgi->startform(-action=>"${cgiURL}dataMunger.pl"), 188 $cgi->startform(-action=>"${cgiURL}dataMunger.pl"),
189 $cgi->submit(-value=>'Examine or change data for psvn:'), "\n", 189 $cgi->submit(-value=>'Examine or change data for psvn:'), "\n",
190 $cgi->textfield(-name=>'probSetKey', -col=>'15', -value=>'Enter PSVN'), "\n", 190 $cgi->textfield(-name=>'probSetKey', -col=>'15', -value=>'Enter PSVN'), "\n",
191 $cgi->hidden(-name=>'save', -value=>'OFF'), "\n", 191 $cgi->hidden(-name=>'save', -value=>'OFF'), "\n",
192 $cgi->hidden(-name=>'firsttime', -value=>1), "\n", 192 $cgi->hidden(-name=>'firsttime', -value=>1), "\n",
232#if a given parameter does not exist, a note is placed in the html to that affect 232#if a given parameter does not exist, a note is placed in the html to that affect
233#this does NOT PRINT the info, so that it can be incorporated into other text 233#this does NOT PRINT the info, so that it can be incorporated into other text
234sub hiddens { 234sub hiddens {
235 my @params = @_; 235 my @params = @_;
236 my $out; 236 my $out;
237 237
238 foreach my $param (@params) { 238 foreach my $param (@params) {
239 if (exists $inputs{$param}) { 239 if (exists $inputs{$param}) {
240 $out .= $cgi->hidden(-name=>"$param", -value=>"$inputs{$param}") . "\n"; 240 $out .= $cgi->hidden(-name=>"$param", -value=>"$inputs{$param}") . "\n";
241 } else { 241 } else {
242 $out .= $cgi->p . "\nExpected cgi parameter $param does not exist or is empty"; 242 $out .= $cgi->p . "\nExpected cgi parameter $param does not exist or is empty";
243 } 243 }
244 } 244 }
245 245
246 $out; 246 $out;
247} 247}

Legend:
Removed from v.850  
changed lines
  Added in v.851

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9