forked from leftypol/leftypol
functions net.php: add Tor connections to secure connections
This commit is contained in:
parent
7dcdbc065d
commit
428d9e9001
|
@ -3,8 +3,15 @@ namespace Vichan\Functions\Net;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool Returns if the client-server connection is an encrypted one (HTTPS).
|
* @return bool Returns if the client-server connection is an HTTPS one.
|
||||||
*/
|
*/
|
||||||
function is_connection_secure(): bool {
|
function is_connection_https(): bool {
|
||||||
return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off';
|
return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool Returns if the client-server connection is an encrypted one (HTTPS or Tor loopback).
|
||||||
|
*/
|
||||||
|
function is_connection_secure(): bool {
|
||||||
|
return is_connection_https() || (!empty($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] === '127.0.0.1');
|
||||||
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ function setCookies() {
|
||||||
if (!$mod)
|
if (!$mod)
|
||||||
error('setCookies() was called for a non-moderator!');
|
error('setCookies() was called for a non-moderator!');
|
||||||
|
|
||||||
$is_https = Net\is_connection_secure();
|
$is_https = Net\is_connection_https();
|
||||||
|
|
||||||
setcookie($config['cookies']['mod'],
|
setcookie($config['cookies']['mod'],
|
||||||
$mod['username'] . // username
|
$mod['username'] . // username
|
||||||
|
@ -120,7 +120,7 @@ function setCookies() {
|
||||||
|
|
||||||
function destroyCookies() {
|
function destroyCookies() {
|
||||||
global $config;
|
global $config;
|
||||||
$is_https = Net\is_connection_secure();
|
$is_https = Net\is_connection_https();
|
||||||
// Delete the cookies
|
// Delete the cookies
|
||||||
setcookie($config['cookies']['mod'], 'deleted', time() - $config['cookies']['expire'], $config['cookies']['jail']?$config['cookies']['path'] : '/', null, $is_https, true);
|
setcookie($config['cookies']['mod'], 'deleted', time() - $config['cookies']['expire'], $config['cookies']['jail']?$config['cookies']['path'] : '/', null, $is_https, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user