Diff for /loncom/homework/lonhomework.pm between versions 1.294 and 1.304

version 1.294, 2008/07/01 11:01:30 version 1.304, 2009/03/04 16:00:14
Line 209  sub proctor_checked_in { Line 209  sub proctor_checked_in {
     return 0;      return 0;
 }  }
   
 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;  
 }  
   
 sub check_slot_access {  sub check_slot_access {
     my ($id,$type)=@_;      my ($id,$type)=@_;
   
Line 307  sub check_slot_access { Line 255  sub check_slot_access {
  &Apache::lonhomework::showhash(%slot);   &Apache::lonhomework::showhash(%slot);
  if ($slot{'starttime'} < time &&   if ($slot{'starttime'} < time &&
     $slot{'endtime'} > time &&      $slot{'endtime'} > time &&
     &check_ip_acc($slot{'ip'})) {      &Apache::loncommon::check_ip_acc($slot{'ip'})) {
     &Apache::lonxml::debug("$slot is good");      &Apache::lonxml::debug("$slot is good");
     $slotstatus='NEEDS_CHECKIN';      $slotstatus='NEEDS_CHECKIN';
     $returned_slot=\%slot;      $returned_slot=\%slot;
Line 421  sub check_access { Line 369  sub check_access {
     #if ($env{'request.state'} ne "construct" && $symb ne '') {      #if ($env{'request.state'} ne "construct" && $symb ne '') {
     if ($env{'request.state'} ne "construct") {      if ($env{'request.state'} ne "construct") {
         my $idacc = &Apache::lonnet::EXT("resource.$id.acc");          my $idacc = &Apache::lonnet::EXT("resource.$id.acc");
  my $allowed=&check_ip_acc($idacc);   my $allowed=&Apache::loncommon::check_ip_acc($idacc);
  if (!$allowed && ($Apache::lonhomework::browse ne 'F')) {   if (!$allowed && ($Apache::lonhomework::browse ne 'F')) {
     $status='INVALID_ACCESS';      $status='INVALID_ACCESS';
     $date=&mt("can not be accessed from your location.");      $date=&mt("can not be accessed from your location.");
Line 923  sub editxmlmode { Line 871  sub editxmlmode {
  &renderpage($request,$file);   &renderpage($request,$file);
     } else {      } else {
  my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem);   my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem);
  my $xml_help = '<table><tr><td>'.  
     &Apache::loncommon::helpLatexCheatsheet("Problem_Editor_XML_Index",  
     "Problem Editing Help").  
     '</td><td>'.  
        &Apache::loncommon::help_open_menu(undef,undef,5,'Authoring').  
                 '</td></tr></table>';  
  if ($cols > 80) { $cols = 80; }   if ($cols > 80) { $cols = 80; }
  if ($cols < 70) { $cols = 70; }   if ($cols < 70) { $cols = 70; }
  if ($rows < 20) { $rows = 20; }   if ($rows < 20) { $rows = 20; }
  my $js =   my $js =
     &Apache::edit::js_change_detection().       &Apache::edit::js_change_detection(). 
     &Apache::loncommon::resize_textarea_js().      &Apache::loncommon::resize_textarea_js().
             &Apache::structuretags::setmode_javascript();              &Apache::structuretags::setmode_javascript().
               &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
  my $only_body =  ($env{'environment.remote'} eq 'off')? 0 : 1;   my $only_body =  ($env{'environment.remote'} eq 'off')? 0 : 1;
  my $dragmath = <<ENDDRAGMATH;   my $dragmath_button = 
                 <script language="JavaScript">              &Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1);
                   function mathedit(textarea, doc) {  
                      targetEntry = textarea;  
      targetDoc   = doc;  
                      newwin  = window.open("/adm/dragmath/applet/EditMathPopup.html","","width=565,height=500,resizable");  
                   }  
                 </script>  
                 <input type="button" value="Edit Math", onclick="javascript:mathedit('LC_editxmltext',document)" />  
 ENDDRAGMATH  
  my $start_page =    my $start_page = 
     &Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js,      &Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js,
    {'no_auto_mt_title' => 1,     {'no_auto_mt_title' => 1,
Line 964  ENDDRAGMATH Line 899  ENDDRAGMATH
               <table class="LC_edit_problem_header_title"><tr><td>                <table class="LC_edit_problem_header_title"><tr><td>
                '.&mt('Problem Editing').&Apache::loncommon::help_open_topic('Problem_Editor_XML_Index').'                 '.&mt('Problem Editing').&Apache::loncommon::help_open_topic('Problem_Editor_XML_Index').'
                 </td><td align="right">                  </td><td align="right">
                   '.&Apache::loncommon::helpLatexCheatsheet().'                    '.&Apache::loncommon::helpLatexCheatsheet('Problem_LON-CAPA_Functions','Script Functions').'
                 </td></tr>                  </td></tr>
               </table>                </table>
               <div class="LC_edit_problem_discards">                <div class="LC_edit_problem_discards">
Line 974  ENDDRAGMATH Line 909  ENDDRAGMATH
                 'onclick="javascript:setmode(this.form,'."'discard'".')" />                  'onclick="javascript:setmode(this.form,'."'discard'".')" />
                 <input type="button" '.&Apache::edit::submit_ask_anyway('setmode(this.form,'."'edit'".')').'name="submitmode" accesskey="e" value="'.&mt('Edit').'" />                  <input type="button" '.&Apache::edit::submit_ask_anyway('setmode(this.form,'."'edit'".')').'name="submitmode" accesskey="e" value="'.&mt('Edit').'" />
                 <input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" />                  <input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" />
                   '.$dragmath_button.'
               </div>                </div>
               <div class="LC_edit_problem_saves">                <div class="LC_edit_problem_saves">
                 <input type="submit" name="submitbutton" accesskey="s" value="'.&mt('Save').'"  />                  <input type="submit" name="submitbutton" accesskey="s" value="'.&mt('Save').'"  />
                 <input type="submit" name="submitbutton" accesskey="v" value="'.&mt('Save and View').'" />'                  <input type="submit" name="submitbutton" accesskey="v" value="'.&mt('Save and View').'" />
  .$dragmath.'  
               </div>                </div>
               <hr class="LC_edit_problem_divide" />                <hr class="LC_edit_problem_divide" />
       '.&Apache::lonxml::message_location().'        '.&Apache::lonxml::message_location().'
Line 1199  sub update_construct_style { Line 1134  sub update_construct_style {
  && !defined($env{'form.newrandomization'})) {   && !defined($env{'form.newrandomization'})) {
  if ((!$env{'form.style_file'} && $env{'construct.style'})   if ((!$env{'form.style_file'} && $env{'construct.style'})
     ||$env{'form.clear_style_file'}) {      ||$env{'form.clear_style_file'}) {
     &Apache::lonnet::delenv('construct\\.style');      &Apache::lonnet::delenv('construct.style');
  } elsif ($env{'form.style_file'}    } elsif ($env{'form.style_file'} 
     && $env{'construct.style'} ne $env{'form.style_file'}) {      && $env{'construct.style'} ne $env{'form.style_file'}) {
     &Apache::lonnet::appenv({'construct.style' =>       &Apache::lonnet::appenv({'construct.style' => 

Removed from v.1.294  
changed lines
  Added in v.1.304


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>