--- loncom/interface/loncommon.pm 2008/09/04 21:22:34 1.678 +++ loncom/interface/loncommon.pm 2008/09/11 15:15:29 1.684 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.678 2008/09/04 21:22:34 riegler Exp $ +# $Id: loncommon.pm,v 1.684 2008/09/11 15:15:29 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1507,9 +1507,9 @@ sub create_text_file { $fh = Apache::File->new('>/home/httpd'.$filename); if (! defined($fh)) { $r->log_error("Couldn't open $filename for output $!"); - $r->print("Problems occured in creating the output file. ". - "This error has been logged. ". - "Please alert your LON-CAPA administrator."); + $r->print(&mt('Problems occurred in creating the output file. ' + .'This error has been logged. ' + .'Please alert your LON-CAPA administrator.')); } return ($fh,$filename) } @@ -3747,6 +3747,60 @@ sub blocking_status { ############################################### +sub check_ip_acc { + my ($acc)=@_; + &Apache::lonxml::debug("acc is $acc"); + if (!defined($acc) || $acc =~ /^\s*$/ || $acc =~/^\s*no\s*$/i) { + return 1; + } + my $allowed=0; + my $ip=$env{'request.host'} || $ENV{'REMOTE_ADDR'}; + + my $name; + foreach my $pattern (split(',',$acc)) { + $pattern =~ s/^\s*//; + $pattern =~ s/\s*$//; + if ($pattern =~ /\*$/) { + #35.8.* + $pattern=~s/\*//; + if ($ip =~ /^\Q$pattern\E/) { $allowed=1; } + } elsif ($pattern =~ /(\d+\.\d+\.\d+)\.\[(\d+)-(\d+)\]$/) { + #35.8.3.[34-56] + my $low=$2; + my $high=$3; + $pattern=$1; + if ($ip =~ /^\Q$pattern\E/) { + my $last=(split(/\./,$ip))[3]; + if ($last <=$high && $last >=$low) { $allowed=1; } + } + } elsif ($pattern =~ /^\*/) { + #*.msu.edu + $pattern=~s/\*//; + if (!defined($name)) { + use Socket; + my $netaddr=inet_aton($ip); + ($name)=gethostbyaddr($netaddr,AF_INET); + } + if ($name =~ /\Q$pattern\E$/i) { $allowed=1; } + } elsif ($pattern =~ /\d+\.\d+\.\d+\.\d+/) { + #127.0.0.1 + if ($ip =~ /^\Q$pattern\E/) { $allowed=1; } + } else { + #some.name.com + if (!defined($name)) { + use Socket; + my $netaddr=inet_aton($ip); + ($name)=gethostbyaddr($netaddr,AF_INET); + } + if ($name =~ /\Q$pattern\E$/i) { $allowed=1; } + } + if ($allowed) { last; } + } + return $allowed; +} + +############################################### + =pod =head1 Domain Template Functions @@ -4493,7 +4547,6 @@ table.LC_docs_path td.LC_docs_path_compo td.LC_table_cell_checkbox { text-align: center; } - table#LC_mainmenu td.LC_mainmenu_column { vertical-align: top; } @@ -4507,7 +4560,7 @@ table#LC_mainmenu td.LC_mainmenu_column .LC_menubuttons_link { text-decoration: none; } - +#2008--9-5: new menu style sheet.Changed category .LC_menubuttons_category { color: $font; background: $pgbg; @@ -5360,8 +5413,31 @@ hr.LC_edit_problem_divide { height: 3px; border: 0px; } -a.stift{ +img.stift{ border-width:0; + vertical-align:middle; +} + +table#LC_mainmenu{ + margin-top:10px; + width:80%; + +} + +table#LC_mainmenu td.LC_mainmenu_col_fieldset{ + vertical-align: top; + width: 45%; +} +.LC_mainmenu_fieldset_category { + color: $font; + background: $pgbg; + font-family: $sans; + font-size: small; + font-weight: bold; +} +fieldset#LC_mainmenu_fieldset { + margin:0px 10px 10px 0px; + } END } @@ -9268,7 +9344,7 @@ sub init_user_environment { } # Give them a new cookie my $id = ($args->{'robot'} ? 'robot'.$args->{'robot'} - : $now); + : $now.$$.int(rand(10000))); $cookie="$username\_$id\_$domain\_$authhost"; # Initialize roles