Changeset - df7edf936f21
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 14 years ago 2011-10-14 20:29:39
ohnobinki@ohnopublishing.net
Support the case where REMOTE_HOST is the same as REMOTE_ADDR.
1 file changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
inc/school.inc
Show inline comments
 
@@ -141,25 +141,27 @@ function school_load_guess($update_sessi
 
	    $_SESSION['school'] = $school['id'];
 
	  return $school;
 
	}
 
    }
 

	
 
  /* assume that we stored a valid school in the $_SESSION */
 
  if (isset($_SESSION['school']))
 
    return school_load($_SESSION['school']);
 

	
 
  if (isset($_SERVER['REMOTE_HOST']) || isset($_SERVER['REMOTE_ADDR']))
 
    {
 
      $addr = NULL;
 
      if (!isset($_SERVER['REMOTE_HOST']))
 
      /* http://ietf.org/rfc/rfc3875 */
 
      if (!isset($_SERVER['REMOTE_HOST'])
 
	  || !strcmp($_SERVER['REMOTE_HOST'], $_SERVER['REMOTE_ADDR']))
 
	$addr = gethostbyaddr($_SERVER['REMOTE_ADDR']);
 

	
 
      $cache = _school_cache_load();
 
      if ($addr && $cache && count($cache['domains']))
 
	{
 
	  $domain_parts = array_reverse(explode('.', $addr));
 
	  $domain_school = $cache['domains'];
 
	  while (is_array($domain_school))
 
	    {
 
	      $domain_part = array_shift($domain_parts);
 
	      if (isset($domain_school[$domain_part]))
 
		$domain_school = $domain_school[$domain_part];
0 comments (0 inline, 0 general)