Browse Source

functions net.php: add Tor connections to secure connections

pull/141/head
Zankaria 3 weeks ago
parent
commit
428d9e9001
  1. 11
      inc/functions/net.php
  2. 4
      inc/mod/auth.php

11
inc/functions/net.php

@ -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 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');
}

4
inc/mod/auth.php

@ -107,7 +107,7 @@ function setCookies() {
if (!$mod)
error('setCookies() was called for a non-moderator!');
$is_https = Net\is_connection_secure();
$is_https = Net\is_connection_https();
setcookie($config['cookies']['mod'],
$mod['username'] . // username
@ -120,7 +120,7 @@ function setCookies() {
function destroyCookies() {
global $config;
$is_https = Net\is_connection_secure();
$is_https = Net\is_connection_https();
// Delete the cookies
setcookie($config['cookies']['mod'], 'deleted', time() - $config['cookies']['expire'], $config['cookies']['jail']?$config['cookies']['path'] : '/', null, $is_https, true);
}

Loading…
Cancel
Save