. */ // Set to true to enable debugging. Should be set to false for production. $debug = false; $resource = $_GET['resource']; $record = $_GET['record']; $out_debug = ""; $remote_ip=@$REMOTE_ADDR; function check_ip($ip) { $campus_ips = array( '140.254', '128.146', '164.107' ); $on = false; foreach ($campus_ips as $ipn){ if(substr($ip,0,strlen($ipn)) == $ipn) $on = true; } return $on; } function check_open($record){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://library.ohio-state.edu/search?/.".$record."/.".$record."/1%2C1%2C1%2CB/marc~".$record); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result = @curl_exec($ch); curl_close($ch); $marc_num = "945"; $open_codes = array( "opensc", "openkb", "opengov" ); foreach($open_codes as $scode){ $marc_line = "$marc_num $scode"; if (strpos($result,$marc_line)) { return true; } } return false; } // First check to see if they are on campus, if so point straight to the resource if(check_ip($remote_ip)) { $out_debug .= "You are on campus!
"; $goto = $resource; } // Check if record is open according to criteria above else if(check_open($record)){ $out_debug .= "This record is open!
"; $goto = $resource; } // If it makes it this far, then the user is off campus trying to access a restricted resource, so it adds the proxy string else { $out_debug .= "You are not on campus!
"; $goto = 'http://proxy.lib.ohio-state.edu/login?url=' . $resource; } if(!$debug) { header('Location: '.$goto); } else { echo "Debug information for Off Campus Validator:

".$out_debug."Resulting Link: $goto"; } ?>