function smarty_modifier_proxify($str) { // @codingStandardsIgnoreEnd global $configArray; if (!isset($configArray['EZproxy']['host']) || !$configArray['EZproxy']['host']) { return $str; } if (isset($configArray['EZproxy']['proxy_known_ip_addresses']) && !$configArray['EZproxy']['proxy_known_ip_addresses'] && UserAccount::isInIpRange()) { return $str; } if (isset($configArray['EZproxy']['include_url']) || isset($configArray['EZproxy']['include_url_re'])) { if (isset($configArray['EZproxy']['include_url'])) { $pass = false; foreach ($configArray['EZproxy']['include_url'] as $mask) { if (strstr($str, $mask)) { $pass = true; break; } } } if (!$pass && isset($configArray['EZproxy']['include_url_re'])) { $pass = false; foreach ($configArray['EZproxy']['include_url_re'] as $mask) { if (preg_match($mask, $str)) { $pass = true; break; } } } if (!$pass) { return $str; } } if (isset($configArray['EZproxy']['exclude_url'])) { foreach ($configArray['EZproxy']['exclude_url'] as $mask) { if (strstr($str, $mask)) { return $str; } } } if (isset($configArray['EZproxy']['exclude_url_re'])) { foreach ($configArray['EZproxy']['exclude_url_re'] as $mask) { if (preg_match($mask, $str)) { return $str; } } } return $configArray['EZproxy']['host'] . '/login?qurl=' . urlencode($str); }
/** * Checks whether the user is authorized to access * restricted resources. * * @return bool Is the user authorized * @access public */ public static function isAuthorized() { global $configArray; if (isset($_SESSION['userAuthorized']) && $_SESSION['userAuthorized']) { return true; } if (isset($configArray['Authorization']['ip']) && $configArray['Authorization']['ip']) { if (UserAccount::isInIpRange()) { return true; } } if (isset($_SESSION['authMethod']) && isset($configArray['Authorization']['authentication_methods'])) { if (in_array($_SESSION['authMethod'], $configArray['Authorization']['authentication_methods'])) { if ($_SESSION['authMethod'] == 'ILS') { if (!isset($_SESSION['userAuthorized'])) { // Check ILS-based authorization $patron = UserAccount::catalogLogin(); if ($patron !== false && !PEAR::isError($patron)) { $catalog = ConnectionManager::connectToCatalog(); if ($catalog->checkFunction('getPatronAuthorizationStatus')) { $status = $catalog->getPatronAuthorizationStatus($patron); if (!PEAR::isError($status)) { $_SESSION['userAuthorized'] = $status; if ($status) { return true; } } } } } } else { return true; } } } return false; }