version 1.152, 2003/10/13 21:09:47
|
version 1.159, 2003/12/22 22:15:27
|
Line 24
|
Line 24
|
# /home/httpd/html/adm/gpl.txt |
# /home/httpd/html/adm/gpl.txt |
# |
# |
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
|
# Guy Albertelli |
|
# 11/30 Gerd Kortemeyer |
|
# 6/1,8/17,8/18 Gerd Kortemeyer |
|
# 7/18 Jeremy Bowers |
|
|
|
package Apache::lonhomework; |
package Apache::lonhomework; |
use strict; |
use strict; |
Line 149 $Apache::lonxml::browse='';
|
Line 145 $Apache::lonxml::browse='';
|
|
|
sub check_ip_acc { |
sub check_ip_acc { |
my ($acc)=@_; |
my ($acc)=@_; |
if (!defined($acc)) { return 1; } |
if (!defined($acc) || $acc =~ /^\s*$/) { return 1; } |
my $allowed=0; |
my $allowed=0; |
my $ip=$ENV{'REMOTE_ADDR'}; |
my $ip=$ENV{'REMOTE_ADDR'}; |
my $name; |
my $name; |
Line 174 sub check_ip_acc {
|
Line 170 sub check_ip_acc {
|
use Socket; |
use Socket; |
my $netaddr=inet_aton($ip); |
my $netaddr=inet_aton($ip); |
($name)=gethostbyaddr($netaddr,AF_INET); |
($name)=gethostbyaddr($netaddr,AF_INET); |
} |
} |
if ($name =~ /\Q$pattern\E$/i) { $allowed=1; } |
if ($name =~ /\Q$pattern\E$/i) { $allowed=1; } |
} elsif ($pattern =~ /\d+\.\d+\.\d+\.\d+/) { |
} elsif ($pattern =~ /\d+\.\d+\.\d+\.\d+/) { |
#127.0.0.1 |
#127.0.0.1 |
Line 216 sub check_access {
|
Line 212 sub check_access {
|
|
|
my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc")); |
my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc")); |
if (!$allowed) { |
if (!$allowed) { |
&Apache::lonnet::logthis("Early exit"); |
|
$status='INVALID_ACCESS'; |
$status='INVALID_ACCESS'; |
$date=&mt("may be open from a different computer."); |
$date=&mt("can not be accessed from your location."); |
return($status,$date); |
return($status,$date); |
} |
} |
|
|
Line 380 sub handle_save_or_undo {
|
Line 375 sub handle_save_or_undo {
|
my $filetmp =$file.".tmp"; |
my $filetmp =$file.".tmp"; |
my $error=0; |
my $error=0; |
|
|
|
&Apache::lonnet::correct_line_ends($result); |
|
|
if ($ENV{'form.Undo'} eq &mt('undo')) { |
if ($ENV{'form.Undo'} eq &mt('undo')) { |
my $error=0; |
my $error=0; |
if (!copy($file,$filetmp)) { $error=1; } |
if (!copy($file,$filetmp)) { $error=1; } |
Line 643 sub newproblem {
|
Line 640 sub newproblem {
|
&renderpage($request,$dest); |
&renderpage($request,$dest); |
} else { |
} else { |
my $url=$request->uri; |
my $url=$request->uri; |
|
my $shownurl=$url; |
|
$shownurl=~s-^/~-/priv/-; |
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
my $errormsg; |
my $errormsg; |
if ($ENV{'form.newfile'}) { |
if ($ENV{'form.newfile'}) { |
$errormsg='<p><font color="red">'.&mt('You did not select a template.').'</font></p>'."\n"; |
$errormsg='<p><font color="red">'.&mt('You did not select a template.').'</font></p>'."\n"; |
} |
} |
my $instructions; |
my $instructions; |
|
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
if ($templatelist) { $instructions=&mt(", select a template from the pull-down menu below.").'<br />'.&mt("Then");} |
if ($templatelist) { $instructions=&mt(", select a template from the pull-down menu below.").'<br />'.&mt("Then");} |
my %lt=&Apache::lonlocal::texthash( 'create' => 'Creating a new', |
my %lt=&Apache::lonlocal::texthash( 'create' => 'Creating a new', |
'resource' => 'resource', |
'resource' => 'resource', |
Line 659 sub newproblem {
|
Line 659 sub newproblem {
|
'Create' => 'Create', |
'Create' => 'Create', |
'button' => 'button'); |
'button' => 'button'); |
$request->print(<<ENDNEWPROBLEM); |
$request->print(<<ENDNEWPROBLEM); |
<body bgcolor="#FFFFFF"> |
$bodytag |
<h1>$lt{'create'} $extension $lt{'resource'}</h1> |
<h1>$lt{'create'} $extension $lt{'resource'}</h1> |
$errormsg |
$errormsg |
$lt{'requested'} <tt>$url</tt> $lt{'not exist'}. |
$lt{'requested'} <tt>$shownurl</tt> $lt{'not exist'}. |
<p> |
<p> |
<b>$lt{'createnew'} $extension$instructions $lt{'click'} "$lt{'Create'} $extension" $lt{'button'}.</b> |
<b>$lt{'createnew'} $extension$instructions $lt{'click'} "$lt{'Create'} $extension" $lt{'button'}.</b> |
</p> |
</p> |