Skip to content

Commit fb19ccc

Browse files
committed
Merge branch 'develop'
2 parents 5c3f618 + b9a496e commit fb19ccc

File tree

5 files changed

+37
-22
lines changed

5 files changed

+37
-22
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
System that automatically grants ranks in the form of server groups for online time or online activity to users, using the given server groups of the TS3 server.
77

8-
This is a modified fork of the TSN-Ranksystem which is updated irregularly to a stable version.
8+
This is a modified fork of the TSN-Ranksystem which is updated irregularly to a stable version. It is intended to be fully compatible to TSN-Ranksystem at all times. The changeset on branch `develop` is always rebased onto TSN-Ranksystem and later on merged into `master`.
9+
10+
Please make sure that your TSN-Ranksystem database version is not above the database version of this fork (downgrade).
911

1012
## Docker
1113
You can find the docker images on [docker hub](https://hub.docker.com/r/jvmerkle/ts3-ranksystem).
@@ -43,6 +45,8 @@ Additions and (security) improvements to [Newcomer1989/TSN-Ranksystem](https://g
4345
- Teamspeak hostname and port (e.g. localhost / abc.xyz)
4446
- ...
4547
- The update __check__ does __not__ enforce SSL peer verification and is therefore insecure
48+
- Secure api key comparison
49+
- No unnecessary webinterface HTTPS warning for rank systems behind a proxy
4650
- Docker-Ready
4751
- Aesthetics:
4852
- Website title is set to "TS3 Ranksystem"

api/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
if (isset($_GET['apikey'])) {
1515
$matchkey = 0;
1616
foreach($cfg['stats_api_keys'] as $apikey => $desc) {
17-
if ($apikey == $_GET['apikey']) $matchkey = 1;
17+
if (hash_equals($apikey, $_GET['apikey'])) $matchkey = 1;
1818
}
1919
if ($matchkey == 0) {
2020
$json = array(
@@ -442,4 +442,4 @@
442442
}
443443

444444
echo json_encode($json);
445-
?>
445+
?>

other/_functions.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,39 @@ function enter_logfile($cfg,$loglevel,$logtext,$norotate = false) {
5555
}
5656
}
5757

58-
function error_handling($msg,$type = NULL) {
58+
function error_handling_str_builder($msg,$type = NULL) {
59+
$string = '';
5960
if(strstr($type, '#') && strstr($msg, '#####')) {
6061
$type_arr = explode('#', $type);
6162
$msg_arr = explode('#####', $msg);
6263
$cnt = 0;
63-
64+
6465
foreach($msg_arr as $msg) {
6566
switch ($type_arr[$cnt]) {
66-
case NULL: echo '<div class="alert alert-success alert-dismissible">'; break;
67-
case 0: echo '<div class="alert alert-success alert-dismissible">'; break;
68-
case 1: echo '<div class="alert alert-info alert-dismissible">'; break;
69-
case 2: echo '<div class="alert alert-warning alert-dismissible">'; break;
70-
case 3: echo '<div class="alert alert-danger alert-dismissible">'; break;
67+
case NULL: $string .= '<div class="alert alert-success alert-dismissible">'; break;
68+
case 0: $string .= '<div class="alert alert-success alert-dismissible">'; break;
69+
case 1: $string .= '<div class="alert alert-info alert-dismissible">'; break;
70+
case 2: $string .= '<div class="alert alert-warning alert-dismissible">'; break;
71+
case 3: $string .= '<div class="alert alert-danger alert-dismissible">'; break;
7172
}
72-
echo '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>',$msg_arr[$cnt],'</div>';
73+
$string .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' . $msg_arr[$cnt] . '</div>';
7374
$cnt++;
7475
}
7576
} else {
7677
switch ($type) {
77-
case NULL: echo '<div class="alert alert-success alert-dismissible">'; break;
78-
case 0: echo '<div class="alert alert-success alert-dismissible">'; break;
79-
case 1: echo '<div class="alert alert-info alert-dismissible">'; break;
80-
case 2: echo '<div class="alert alert-warning alert-dismissible">'; break;
81-
case 3: echo '<div class="alert alert-danger alert-dismissible">'; break;
78+
case NULL: $string .= '<div class="alert alert-success alert-dismissible">'; break;
79+
case 0: $string .= '<div class="alert alert-success alert-dismissible">'; break;
80+
case 1: $string .= '<div class="alert alert-info alert-dismissible">'; break;
81+
case 2: $string .= '<div class="alert alert-warning alert-dismissible">'; break;
82+
case 3: $string .= '<div class="alert alert-danger alert-dismissible">'; break;
8283
}
83-
echo '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>',$msg,'</div>';
84+
$string .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' . $msg . '</div>';
8485
}
86+
return $string;
87+
}
88+
89+
function error_handling($msg,$type = NULL) {
90+
echo error_handling_str_builder($msg,$type);
8591
}
8692

8793
function getclientip() {
@@ -480,4 +486,4 @@ function start_session($cfg) {
480486
session_start();
481487
return $prot;
482488
}
483-
?>
489+
?>

webinterface/_nav.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,12 @@
269269
$err_msg = $lang['winav11']; $err_lvl = 2;
270270
}
271271

272-
if((!isset($_SERVER['HTTPS']) || isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "on") && !isset($err_msg) && basename($_SERVER['SCRIPT_NAME']) == "index.php") {
272+
$js_test_https = '';
273+
if(!isset($err_msg) && basename($_SERVER['SCRIPT_NAME']) == "index.php") {
273274
$host = "<a href=\"https://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."\">";
274-
$err_msg = sprintf($lang['winav10'], $host,'</a>!<br>', '<br>'); $err_lvl = 2;
275+
$msg = sprintf($lang['winav10'], $host,'</a>!<br>', '<br>');
276+
$js_test_https = '<script> if (location.protocol !== \'https:\') {';
277+
$js_test_https .= 'document.write(\'' . error_handling_str_builder($msg, 2) . '\')';
278+
$js_test_https .= '} </script>';
275279
}
276-
?>
280+
?>

webinterface/index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
?>
103103
<div id="page-wrapper">
104104
<?PHP if(isset($err_msg)) error_handling($err_msg, $err_lvl); ?>
105+
<?PHP echo $js_test_https ?>
105106
<div class="container-fluid">
106107
<div id="login-overlay" class="modal-dialog">
107108
<div class="modal-content">
@@ -152,4 +153,4 @@
152153
</html>
153154
<?PHP
154155
} catch(Throwable $ex) { }
155-
?>
156+
?>

0 commit comments

Comments
 (0)