Rev 555 | Rev 558 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 555 | Rev 557 | ||
---|---|---|---|
Line 235... | Line 235... | ||
235 | self::$mailUtils = new OIDplusMailUtils(); |
235 | self::$mailUtils = new OIDplusMailUtils(); |
236 | } |
236 | } |
237 | return self::$mailUtils; |
237 | return self::$mailUtils; |
238 | } |
238 | } |
239 | 239 | ||
- | 240 | private static $cookieUtils = null; |
|
- | 241 | public static function cookieUtils() { |
|
- | 242 | if (is_null(self::$cookieUtils)) { |
|
- | 243 | self::$cookieUtils = new OIDplusCookieUtils(); |
|
- | 244 | } |
|
- | 245 | return self::$cookieUtils; |
|
- | 246 | } |
|
- | 247 | ||
240 | private static $menuUtils = null; |
248 | private static $menuUtils = null; |
241 | public static function menuUtils() { |
249 | public static function menuUtils() { |
242 | if (is_null(self::$menuUtils)) { |
250 | if (is_null(self::$menuUtils)) { |
243 | self::$menuUtils = new OIDplusMenuUtils(); |
251 | self::$menuUtils = new OIDplusMenuUtils(); |
244 | } |
252 | } |
Line 1040... | Line 1048... | ||
1040 | if ($mode == 2) { |
1048 | if ($mode == 2) { |
1041 | // Automatic SSL detection |
1049 | // Automatic SSL detection |
1042 | 1050 | ||
1043 | if ($already_ssl) { |
1051 | if ($already_ssl) { |
1044 | // we are already on HTTPS |
1052 | // we are already on HTTPS |
1045 | op_setcookie('SSL_CHECK', '1', 0, false); |
1053 | OIDplus::cookieUtils()->setcookie('SSL_CHECK', '1', 0, false); |
1046 | self::$sslAvailableCache = true; |
1054 | self::$sslAvailableCache = true; |
1047 | return true; |
1055 | return true; |
1048 | } else { |
1056 | } else { |
1049 | if (isset($_COOKIE['SSL_CHECK'])) { |
1057 | if (isset($_COOKIE['SSL_CHECK'])) { |
1050 | // We already had the HTTPS detection done before. |
1058 | // We already had the HTTPS detection done before. |
Line 1064... | Line 1072... | ||
1064 | // This is our first check (or the browser didn't accept the SSL_CHECK cookie) |
1072 | // This is our first check (or the browser didn't accept the SSL_CHECK cookie) |
1065 | $errno = -1; |
1073 | $errno = -1; |
1066 | $errstr = ''; |
1074 | $errstr = ''; |
1067 | if (@fsockopen($_SERVER['HTTP_HOST'], $ssl_port, $errno, $errstr, $timeout)) { |
1075 | if (@fsockopen($_SERVER['HTTP_HOST'], $ssl_port, $errno, $errstr, $timeout)) { |
1068 | // HTTPS detected. Redirect now, and remember that we had detected HTTPS |
1076 | // HTTPS detected. Redirect now, and remember that we had detected HTTPS |
1069 | op_setcookie('SSL_CHECK', '1', 0, false); |
1077 | OIDplus::cookieUtils()->setcookie('SSL_CHECK', '1', 0, false); |
1070 | $location = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
1078 | $location = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
1071 | header('Location:'.$location); |
1079 | header('Location:'.$location); |
1072 | die(_L('Redirecting to HTTPS...')); |
1080 | die(_L('Redirecting to HTTPS...')); |
1073 | self::$sslAvailableCache = true; |
1081 | self::$sslAvailableCache = true; |
1074 | return true; |
1082 | return true; |
1075 | } else { |
1083 | } else { |
1076 | // No HTTPS detected. Do nothing, and next time, don't try to detect HTTPS again. |
1084 | // No HTTPS detected. Do nothing, and next time, don't try to detect HTTPS again. |
1077 | op_setcookie('SSL_CHECK', '0', 0, false); |
1085 | OIDplus::cookieUtils()->setcookie('SSL_CHECK', '0', 0, false); |
1078 | self::$sslAvailableCache = false; |
1086 | self::$sslAvailableCache = false; |
1079 | return false; |
1087 | return false; |
1080 | } |
1088 | } |
1081 | } |
1089 | } |
1082 | } |
1090 | } |
Line 1167... | Line 1175... | ||
1167 | // The "?lang=" argument is only for NoScript-Browsers/SearchEngines |
1175 | // The "?lang=" argument is only for NoScript-Browsers/SearchEngines |
1168 | // In case someone who has JavaScript clicks a ?lang= link, they should get |
1176 | // In case someone who has JavaScript clicks a ?lang= link, they should get |
1169 | // the page in that language, but the cookie must be set, otherwise |
1177 | // the page in that language, but the cookie must be set, otherwise |
1170 | // the menu and other stuff would be in their cookie-based-language and not the |
1178 | // the menu and other stuff would be in their cookie-based-language and not the |
1171 | // argument-based-language. |
1179 | // argument-based-language. |
1172 | op_setcookie('LANGUAGE', $_GET['lang'], 0, true/*HttpOnly off, because JavaScript also needs translation*/); |
1180 | OIDplus::cookieUtils()->setcookie('LANGUAGE', $_GET['lang'], 0, true/*HttpOnly off, because JavaScript also needs translation*/); |
1173 | } else if (isset($_POST['lang'])) { |
1181 | } else if (isset($_POST['lang'])) { |
1174 | op_setcookie('LANGUAGE', $_POST['lang'], 0, true/*HttpOnly off, because JavaScript also needs translation*/); |
1182 | OIDplus::cookieUtils()->setcookie('LANGUAGE', $_POST['lang'], 0, true/*HttpOnly off, because JavaScript also needs translation*/); |
1175 | } |
1183 | } |
1176 | } |
1184 | } |
1177 | 1185 | ||
1178 | private static $translationArray = array(); |
1186 | private static $translationArray = array(); |
1179 | protected static function getTranslationFileContents($translation_file) { |
1187 | protected static function getTranslationFileContents($translation_file) { |