diff --git a/config.php b/config.php index afef684..8e466ce 100644 --- a/config.php +++ b/config.php @@ -30,7 +30,7 @@ // ------------------------ \\ if ($config['ServerEngine'] !== 'OTHIRE') { - + // TFS DATABASE CONFIGS // phpmyadmin username for OT server: (DONT USE "root" if ur hosting to public.). $config['sqlUser'] = 'tfs13'; @@ -44,7 +44,7 @@ // Hostname is usually localhost or 127.0.0.1. $config['sqlHost'] = '127.0.0.1'; } else { - + // OTHIRE DATABASE CONFIG // phpmyadmin username for OT server: (DONT USE "root" if ur hosting to public.). $config['sql_user'] = 'tfs13'; @@ -56,7 +56,7 @@ $config['sql_db'] = 'tfs13'; // Hostname is usually localhost or 127.0.0.1. - $config['sql_host'] = '127.0.0.1'; + $config['sql_host'] = '127.0.0.1'; } // QR code authenticator Only works with TFS 1.2+ @@ -1027,6 +1027,7 @@ // You can find your secret token by logging in on OTServers.eu and go to 'MY SERVER' then 'Encourage players to vote'. $config['otservers_eu_voting'] = [ 'enabled' => false, + 'simpleVoteUrl' => '', //This url is used if the player isn't logged in. 'voteUrl' => 'https://api.otservers.eu/vote_link.php', 'voteCheckUrl' => 'https://api.otservers.eu/vote_check.php', 'secretToken' => '', //Enter your secret token. Do not share with anyone! diff --git a/layout/aside.php b/layout/aside.php index de36910..a3f3dba 100644 --- a/layout/aside.php +++ b/layout/aside.php @@ -6,7 +6,7 @@ include 'layout/widgets/login.php'; } if (user_logged_in() && is_admin($user_data)) include 'layout/widgets/Wadmin.php'; - if (user_logged_in()) include 'layout/widgets/vote.php'; + if ($config['otservers_eu_voting']['enabled']) include 'layout/widgets/vote.php'; include 'layout/widgets/charactersearch.php'; include 'layout/widgets/topplayers.php'; include 'layout/widgets/highscore.php'; diff --git a/voting.php b/voting.php index 4234f3b..231c763 100644 --- a/voting.php +++ b/voting.php @@ -1,34 +1,38 @@ -Something went wrong! Could not make a vote request.

'; - } else { - header('Location: ' . $result['voteLink']); - die; - } - } else { - $result = checkHasVoted($user_data['id'], $otservers_eu_voting); - if ($result !== false) { - if ($result['voted'] === true) { - $points = $otservers_eu_voting['points']; - $pointsText = $points === '1' ? 'point' : 'points'; - mysql_update("UPDATE `znote_accounts` SET `points` = `points` + '$points' WHERE `account_id`=" . $user_data['id']); - echo "

Thank you for voting! You have been rewarded with $points $pointsText!

"; + if (user_logged_in()) { + $isRewardRequest = isset($_GET['action']) && $_GET['action'] === 'reward'; + if (!$isRewardRequest) { + $result = vote($user_data['id'], $otservers_eu_voting); + if ($result === false) { + echo '

Something went wrong! Could not make a vote request.

'; } else { - echo '

It does not seem like you have voted.

'; + header('Location: ' . $result['voteLink']); + die; } } else { - echo '

Could not verify that you have voted.

'; + $result = checkHasVoted($user_data['id'], $otservers_eu_voting); + if ($result !== false) { + if ($result['voted'] === true) { + $points = $otservers_eu_voting['points']; + $pointsText = $points === '1' ? 'point' : 'points'; + mysql_update("UPDATE `znote_accounts` SET `points` = `points` + '$points' WHERE `account_id`=" . $user_data['id']); + echo "

Thank you for voting! You have been rewarded with $points $pointsText!

"; + } else { + echo '

It does not seem like you have voted.

'; + } + } else { + echo '

Could not verify that you have voted.

'; + } } + } else { + header('Location: ' . $otservers_eu_voting['simpleVoteUrl']); + die; } } else { echo '

Voting is not enabled.

';