From 7c6414e752453ff4069e00cb47e8b7f4e825cf62 Mon Sep 17 00:00:00 2001 From: SilicaAndPina Date: Sun, 27 Jun 2021 15:45:55 +1200 Subject: [PATCH] add sub check --- WebInterface/game-site/account.php | 17 +++++++-- WebInterface/game-site/config.php | 3 +- WebInterface/game-site/web/crosserver.php | 43 +++++++++++++++++++++++ WebInterface/master-site/crosserver.php | 43 +++++++++++++++++++++++ 4 files changed, 103 insertions(+), 3 deletions(-) diff --git a/WebInterface/game-site/account.php b/WebInterface/game-site/account.php index ba918c8..fe66d03 100755 --- a/WebInterface/game-site/account.php +++ b/WebInterface/game-site/account.php @@ -77,6 +77,13 @@ $loginDate = getUserLoginDate($dbname, $_SESSION['PLAYER_ID']); $questPoints = getUserQuestPoints($dbname, $_SESSION['PLAYER_ID']); $totalLogins = getUserTotalLogins($dbname, $_SESSION['PLAYER_ID']); +$subbed = getUserSubbed($dbname, $_SESSION['PLAYER_ID']); +$subTime = getUserSubTimeRemaining($dbname, $_SESSION['PLAYER_ID']); +$playtime = getUserPlaytime($dbname, $_SESSION['PLAYER_ID']); + +if($all_users_subbed) + $subbed = true; + $hasIntl = function_exists('numfmt_create'); if($hasIntl) @@ -176,8 +183,14 @@ h+=60;//h += 96; $difference = $current_time - $loginDate; $lastOn = $difference/60; - echo('It has been: '.$lastOn.' hours since you were last online. You have logged in '.$totalLoginsStr.' times.
You have $'.$moneyStr.' in Horse Isle money on hand and $'.$bankmoneyStr.' in the bank.
You have earned '.(string)$questPoints.' of 63005 total quest points ('.(string)floor(($questPoints / 63005) * 100.0).'% Complete)


'); -?> + + echo('It has been: '.$lastOn.' hours since you were last online. You have logged in '.$totalLoginsStr.' times.
You have $'.$moneyStr.' in Horse Isle money on hand and $'.$bankmoneyStr.' in the bank.
You have earned '.(string)$questPoints.' of 63005 total quest points ('.(string)floor(($questPoints / 63005) * 100.0).'% Complete)
'); + if(!$subbed) + { + echo('You have '.(string)$playtime.' minutes of playtime available. As a non-subscriber you get 1 additional minute every 8 minutes. (subject to change based on load) (why limited?)
'); + } + +?>

diff --git a/WebInterface/game-site/config.php b/WebInterface/game-site/config.php index fd39191..2f55325 100755 --- a/WebInterface/game-site/config.php +++ b/WebInterface/game-site/config.php @@ -7,6 +7,7 @@ $dbuser = 'root'; $dbpass = 'test123'; $dbhost = '127.0.0.1'; +$all_users_subbed = false; $server_id = "beta"; # == hmac_secret == @@ -15,7 +16,7 @@ $server_id = "beta"; # NOTE: if someone knows this secret they can login to ANYONES account # Ideally, this would be a random string of numbers, letters and symbols like 20 characters long T-T $hmac_secret = "!!NOTSET!!"; -$master_site = "//server.islehorse.com"; +$master_site = "//localhost"; # Password for /web/admin $admin_portal_password = "!!NOTSET!!"; ?> diff --git a/WebInterface/game-site/web/crosserver.php b/WebInterface/game-site/web/crosserver.php index 2c765e2..980fb5c 100644 --- a/WebInterface/game-site/web/crosserver.php +++ b/WebInterface/game-site/web/crosserver.php @@ -100,6 +100,49 @@ function getUserTotalLogins($database, $id) } +function getUserPlaytime($database, $id) +{ + include('config.php'); + $dbname = $database; + $connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'"); + $stmt = $connect->prepare("SELECT FreeMinutes FROM UserExt WHERE Id=?"); + $stmt->bind_param("i", $id); + $stmt->execute(); + $result = $stmt->get_result(); + + return intval($result->fetch_row()[0]); + +} + + +function getUserSubTimeRemaining($database, $id) +{ + include('config.php'); + $dbname = $database; + $connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'"); + $stmt = $connect->prepare("SELECT SubscribedUntil FROM UserExt WHERE Id=?"); + $stmt->bind_param("i", $id); + $stmt->execute(); + $result = $stmt->get_result(); + + return intval($result->fetch_row()[0]); + +} + +function getUserSubbed($database, $id) +{ + include('config.php'); + $dbname = $database; + $connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'"); + $stmt = $connect->prepare("SELECT Subscriber FROM UserExt WHERE Id=?"); + $stmt->bind_param("i", $id); + $stmt->execute(); + $result = $stmt->get_result(); + + return $result->fetch_row()[0] == "YES"; + +} + function getNoModPlayersOnlineInServer($database) { diff --git a/WebInterface/master-site/crosserver.php b/WebInterface/master-site/crosserver.php index 2c765e2..980fb5c 100644 --- a/WebInterface/master-site/crosserver.php +++ b/WebInterface/master-site/crosserver.php @@ -100,6 +100,49 @@ function getUserTotalLogins($database, $id) } +function getUserPlaytime($database, $id) +{ + include('config.php'); + $dbname = $database; + $connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'"); + $stmt = $connect->prepare("SELECT FreeMinutes FROM UserExt WHERE Id=?"); + $stmt->bind_param("i", $id); + $stmt->execute(); + $result = $stmt->get_result(); + + return intval($result->fetch_row()[0]); + +} + + +function getUserSubTimeRemaining($database, $id) +{ + include('config.php'); + $dbname = $database; + $connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'"); + $stmt = $connect->prepare("SELECT SubscribedUntil FROM UserExt WHERE Id=?"); + $stmt->bind_param("i", $id); + $stmt->execute(); + $result = $stmt->get_result(); + + return intval($result->fetch_row()[0]); + +} + +function getUserSubbed($database, $id) +{ + include('config.php'); + $dbname = $database; + $connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'"); + $stmt = $connect->prepare("SELECT Subscriber FROM UserExt WHERE Id=?"); + $stmt->bind_param("i", $id); + $stmt->execute(); + $result = $stmt->get_result(); + + return $result->fetch_row()[0] == "YES"; + +} + function getNoModPlayersOnlineInServer($database) {