Compare commits

..

No commits in common. "master" and "1.6" have entirely different histories.
master ... 1.6

23 changed files with 1385 additions and 1589 deletions

View File

@ -25,23 +25,23 @@ end
-- SQL Query to execute: --
--[[
ALTER TABLE `znote_players` ADD `exphist_lastexp` BIGINT NOT NULL DEFAULT '0',
ADD `exphist1` BIGINT NOT NULL DEFAULT '0',
ADD `exphist2` BIGINT NOT NULL DEFAULT '0',
ADD `exphist3` BIGINT NOT NULL DEFAULT '0',
ADD `exphist4` BIGINT NOT NULL DEFAULT '0',
ADD `exphist5` BIGINT NOT NULL DEFAULT '0',
ADD `exphist6` BIGINT NOT NULL DEFAULT '0',
ADD `exphist7` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetimetoday` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime1` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime2` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime3` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime4` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime5` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime6` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime7` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetimeall` INT UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE `znote_players` ADD `exphist_lastexp` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist1` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist2` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist3` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist4` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist5` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist6` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist7` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetimetoday` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime1` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime2` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime3` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime4` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime5` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime6` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime7` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetimeall` BIGINT NOT NULL DEFAULT '0';
]]--
-- after that execute: --

View File

@ -25,23 +25,23 @@ end
-- SQL Query to execute: --
--[[
ALTER TABLE `znote_players` ADD `exphist_lastexp` BIGINT NOT NULL DEFAULT '0',
ADD `exphist1` BIGINT NOT NULL DEFAULT '0',
ADD `exphist2` BIGINT NOT NULL DEFAULT '0',
ADD `exphist3` BIGINT NOT NULL DEFAULT '0',
ADD `exphist4` BIGINT NOT NULL DEFAULT '0',
ADD `exphist5` BIGINT NOT NULL DEFAULT '0',
ADD `exphist6` BIGINT NOT NULL DEFAULT '0',
ADD `exphist7` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetimetoday` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime1` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime2` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime3` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime4` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime5` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime6` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetime7` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetimeall` INT UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE `znote_players` ADD `exphist_lastexp` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist1` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist2` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist3` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist4` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist5` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist6` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist7` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetimetoday` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime1` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime2` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime3` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime4` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime5` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime6` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime7` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetimeall` BIGINT NOT NULL DEFAULT '0';
]]--
-- after that execute: --

View File

@ -13,6 +13,13 @@ We use github to distribute our versions, stable are tagged as releases, while d
* [Stable](https://github.com/Znote/ZnoteAAC/releases)
* [Development](https://github.com/Znote/ZnoteAAC/archive/master.zip)
### Compatible OT distributions
Znote AAC primarily aims to be compatible with [Forgotten Server](https://github.com/otland/forgottenserver)
Forgotten Server is commonly known as TFS (The Forgotten Server) and Znote AAC supports these versions:
* TFS 0.2.13+ (Since initial release)
* TFS 0.3.6+ (Since Znote AAC 1.2)
* TFS 1.2+ (Since Znote AAC 1.5)
### Requirements
* PHP Version 5.6 or higher. Mostly tested on 5.6 and 7.4. Most web stacks ships with this as default these days.
@ -20,7 +27,6 @@ We use github to distribute our versions, stable are tagged as releases, while d
* For email registration verification and account recovery: [PHPMailer](https://github.com/PHPMailer/PHPMailer/releases) Version 6.x, extracted and renamed to just "PHPMailer" in Znote AAC directory.
* PHP extension curl for PHPMailer, paypal and google reCaptcha services.
* PHP extension openssl for google reCaptcha services.
* PHP extension gd for guild logos.
### Installation instructions
@ -48,15 +54,11 @@ This will show you the rest of the instructions as well as the mysql schema.
Znote AAC is very rich feature wise, here is an attempt at summarizing what we offer.
#### Server distribution compatibility:
- [Znote AAC 1.6](https://github.com/Znote/ZnoteAAC/releases/tag/1.6)
- OTHire
- TFS 0.2
- TFS 0.3/4
- TFS 1.3
- Distributions based on these (such as OTX).
- Znote AAC 2.0 [v2 dev branch](https://github.com/Znote/ZnoteAAC/tree/v2)
- TFS 1.4
- OTservBR-Global
- OTHire
- TFS 0.2
- TFS 0.3/4
- TFS 1.x
- Distributions based on these (such as OTX).
#### General
- Server wide latest death list

View File

@ -54,7 +54,6 @@ if (user_logged_in()) {
<h1>Changelog</h1>
<?php
$cache = new Cache('engine/cache/changelog');
$cache->useMemory(false);
if ($updateCache === true) {
$changelogs = mysql_select_multi("SELECT `id`, `text`, `time`, `report_id`, `status` FROM `znote_changelog` ORDER BY `id` DESC;");

View File

@ -87,13 +87,6 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
<td>Position</td>
<td><?php echo group_id_to_name($profile_data['group_id']); ?></td>
</tr>
<?php endif;
// pending deletion?
$deletion_time = mysql_select_single("SELECT `time` FROM `znote_deleted_characters` WHERE `character_name`='{$name}' AND `done` = '0' LIMIT 1;");
if ($deletion_time !== false): ?>
<tr>
<td colspan="2" style="color: red;">Flagged for deletion by owner after <?php echo $deletion_time['time']; ?>.</td>
</tr>
<?php endif; ?>
<!-- Player male / female -->
<tr>

View File

@ -537,7 +537,6 @@
// Minimum allowed letters in character name. Ex: 4 letters: "Kare".
$config['minL'] = 3;
// Maximum allowed letters in character name. Ex: 20 letters: "Bobkareolesofiesberg"
// Pre QT clients (lower than version 11) support only 20 letters max, while newer clients support up to 25
$config['maxL'] = 20;
// Maximum allowed words in character name. Ex: 2 words = "Bob Kare", 3 words: "Bob Arne Kare" as maximum char name words.
$config['maxW'] = 3;
@ -658,18 +657,9 @@
'port' => 7172,
'name' => 'Forgotten' // Must be identical to config.lua (OT config file) server name.
);
// Unlock all protocol 12 client features? Free premium in config.lua? Then set this to true.
$config['freePremium'] = true;
// How often do you want highscores (cache) to update?
$config['cache'] = array(
// If you have two instances installed on same server, make each instance prefix unique
'prefix' => 'znote_',
// 60 * 15; // 15 minutes.
'lifespan' => 5,
// Store cache in memory/RAM? Requires PHP extension APCu
'memory' => true
);
// How often do you want highscores to update?
$config['cache_lifespan'] = 5; // 60 * 15; // 15 minutes.
// WARNING! Account names written here will have admin access to web page!
$config['page_admin_access'] = array(

View File

@ -67,7 +67,7 @@ if (empty($_POST) === false) {
}
// Char count
$char_count = user_character_list_count($session_user_id);
if ($char_count >= $config['max_characters'] && !is_admin($user_data)) {
if ($char_count >= $config['max_characters']) {
$errors[] = 'Your account is not allowed to have more than '. $config['max_characters'] .' characters.';
}
if (validate_ip(getIP()) === false && $config['validate_IP'] === true) {

File diff suppressed because it is too large Load Diff

View File

@ -7,8 +7,9 @@ if (!function_exists("elapsedTime")) {
if ($l_start === false) global $l_start;
if ($l_time === false) global $l_time;
$l_time = microtime(true);
return round(($l_time - $l_start), 4);
$l_time = explode(' ', microtime());
$l_finish = $l_time[1] + $l_time[0];
return round(($l_finish - $l_start), 4);
}
}

View File

@ -1,7 +1,10 @@
<footer>
&copy; Znote AAC.
<?php
$finish = microtime(true);
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo 'Server date and clock is: '. getClock(false, true) .' Page generated in '. $total_time .' seconds. ';
?>

View File

@ -1,12 +1,10 @@
<?php
class Cache
{
class Cache
{
protected $_file = false;
protected $_lifespan = 0;
protected $_content;
protected $_memory = false;
protected $_canMemory = false;
const EXT = '.cache.php';
@ -17,22 +15,8 @@ class Cache
* @return void
**/
public function __construct($file) {
$cfg = config('cache');
$this->setExpiration($cfg['lifespan']);
if (function_exists('apcu_fetch')) {
$this->_canMemory = true;
$this->_memory = $cfg['memory'];
}
$this->_file = $file . self::EXT;
if (!$this->_memory && $cfg['memory']) die("
<p><strong>Configuration error!</strong>
<br>Cannot save cache to memory, but it is configured to do so.
<br>You need to enable PHP extension APCu to enable memory cache.
<br>Install it or set \$config['cache']['memory'] to false!
<br><strong>Ubuntu install:</strong> sudo apt install php-apcu</p>
");
$this->setExpiration(config('cache_lifespan'));
}
@ -48,23 +32,6 @@ class Cache
}
/**
* Enable or disable memory RAM storage.
*
* @param bool $bool
* @access public
* @return bool $status
**/
public function useMemory($bool) {
if ($bool and $this->_canMemory) {
$this->_memory = true;
return true;
}
$this->_memory = false;
return false;
}
/**
* Set the content you'd like to cache.
*
@ -73,7 +40,15 @@ class Cache
* @return void
**/
public function setContent($content) {
$this->_content = (!$this->_memory && strtolower(gettype($content)) == 'array') ? json_encode($content) : $content;
switch (strtolower(gettype($content))) {
case 'array':
$this->_content = json_encode($content);
break;
default:
$this->_content = $content;
break;
}
}
@ -84,12 +59,10 @@ class Cache
* @return boolean
**/
public function hasExpired() {
if ($this->_memory) {
return !apcu_exists($this->_file);
}
if (is_file($this->_file) && time() < filemtime($this->_file) + $this->_lifespan) {
return false;
}
return true;
}
@ -101,18 +74,6 @@ class Cache
**/
public function remainingTime() {
$remaining = 0;
if ($this->_memory) {
if (apcu_exists($this->_file)) {
$meta = apcu_cache_info();
foreach ($meta['cache_list'] AS $item) {
if ($item['info'] == $this->_file) {
$remaining = ($item['creation_time'] + $item['ttl']) - time();
return ($remaining > 0) ? $remaining : 0;
}
}
}
return $remaining;
}
if (!$this->hasExpired()) {
$remaining = (filemtime($this->_file) + $this->_lifespan) - time();
}
@ -127,9 +88,6 @@ class Cache
* @return void
**/
public function save() {
if ($this->_memory) {
return apcu_store($this->_file, $this->_content, $this->_lifespan);
}
$handle = fopen($this->_file, 'w');
fwrite($handle, $this->_content);
fclose($handle);
@ -143,9 +101,6 @@ class Cache
* @return mixed
**/
public function load() {
if ($this->_memory) {
return apcu_fetch($this->_file);
}
if (!is_file($this->_file)) {
return false;
}
@ -164,4 +119,4 @@ class Cache
return $content;
}
}
}
}

View File

@ -231,7 +231,7 @@ function validate_name($string) {
// Checks if an IPv4(or localhost IPv6) address is valid
function validate_ip($ip) {
$ipL = safeIp2Long($ip);
$ipR = long2ip((int)$ipL);
$ipR = long2ip($ipL);
if ($ip === $ipR) {
return true;

View File

@ -1125,13 +1125,13 @@ function user_account_add_premdays($accid, $days) {
} else {
mysql_update(" UPDATE `accounts`
SET `premdays` = `premdays`+{$days}
,`lastday` = GREATEST(`lastday`,UNIX_TIMESTAMP()) + ({$days} * 86400)
,`lastday` = GREATEST(`lastday`,UNIX_TIMESTAMP(CURDATE())) + ({$days} * 86400)
WHERE `id`='{$accid}'
");
}
} else {
mysql_update(" UPDATE `accounts`
SET `premium_ends_at` = GREATEST(`premium_ends_at`, UNIX_TIMESTAMP()) + ({$days} * 86400)
SET `premium_ends_at` = GREATEST(`premium_ends_at`, UNIX_TIMESTAMP(CURDATE())) + ({$days} * 86400)
WHERE `id`='{$accid}';
");
}

View File

@ -1,6 +1,8 @@
<?php if (version_compare(phpversion(), '5.6', '<')) die('PHP version 5.6 or higher is required.');
$l_time = microtime(true);
$l_time = microtime();
$l_time = explode(' ', $l_time);
$l_time = $l_time[1] + $l_time[0];
$l_start = $l_time;
function elapsedTime($l_start = false, $l_time = false) {

View File

@ -281,17 +281,16 @@ if (user_logged_in() === true) {
echo '<td>Remove:</td>';
}
// Shuffle through visitor characters
$exist = false;
for ($i = 0; $i < $char_count; $i++) {
$exist = false;
// Shuffle through invited character, see if they match your character.
if ($inv_data !== false) foreach ($inv_data as $inv) {
if ($charactersId[$i] == $inv['player_id']) {
$exist = true;
break;
}
}
}
if ($exist) echo '<td>Join Guild:</td><td>Reject Invitation:</td>';
}
?>
</tr>
<?php

View File

@ -1,4 +1,4 @@
<?php if(isset($_SERVER["HTTP_USER_AGENT"]) && $_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0") { require_once 'login.php'; die(); } // Client 11 loginWebService
<?php if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0") { require_once 'login.php'; die(); } // Client 11 loginWebService
require_once 'engine/init.php'; include 'layout/overall/header.php';
if (!isset($_GET['page'])) {
@ -15,7 +15,6 @@ require_once 'engine/init.php'; include 'layout/overall/header.php';
// Changelog ticker //
// Load from cache
$changelogCache = new Cache('engine/cache/changelog');
$changelogCache->useMemory(false);
$changelogs = $changelogCache->load();
if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {

View File

@ -229,9 +229,6 @@ table, .header, .well, .smedia a {
}
/* Znote AAC */
.leftPane img {
max-width: 100%;
}
/* adding button style to select */
select {
background: rgb(15,17,20);

View File

@ -4,7 +4,6 @@ if ($config['UseChangelogTicker']) {
// Changelog ticker //
// Load from cache
$changelogCache = new Cache('engine/cache/changelog');
$changelogCache->useMemory(false);
$changelogs = $changelogCache->load();
if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {

View File

@ -29,7 +29,7 @@
}
?>
<script type="text/javascript">
window.searchNames = <?php echo json_encode($names); ?>;
window.searchNames = <?php echo json_encode($names)?>;
$(function() {
if (window.searchNames.length > 0) {
$('#src_name').keyup(function(e) {

View File

@ -5,7 +5,7 @@
<div class="body">
<form class="loginForm" action="login.php" method="post">
<div class="well">
<label for="login_username">Username:</label> <input type="text" name="username" id="login_username">
<label for="login_username">Userame:</label> <input type="text" name="username" id="login_username">
</div>
<div class="well">
<label for="login_password">Password:</label> <input type="password" name="password" id="login_password">

View File

@ -154,7 +154,7 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
$password = SHA1($client->password);
$token = (isset($client->token)) ? sanitize($client->token) : false;
$fields = '`id`, `premium_ends_at`';
$fields = '`id`, `premdays`';
if ($config['twoFactorAuthenticator']) $fields .= ', `secret`';
$account = false;
@ -213,10 +213,8 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
}
$sessionKey = ($email !== false) ? $email."\n".$client->password : $username."\n".$client->password;
$sessionKey .= (isset($account['secret']) && strlen($account['secret']) > 5) ? "\n".$token : "\n";
$sessionKey .= "\n".floor(time() / 30);
if (isset($account['secret']) && strlen($account['secret']) > 5) $sessionKey .= "\n".$token."\n".floor(time() / 30);
$freePremium = (isset($config['freePremium'])) ? $config['freePremium'] : true;
$response = array(
'session' => array(
'fpstracking' => false,
@ -228,8 +226,8 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
'emailcoderequest' => false,
'sessionkey' => $sessionKey,
'lastlogintime' => 0,
'ispremium' => ($account['premium_ends_at'] > time() || $freePremium) ? true : false,
'premiumuntil' => $account['premium_ends_at'],
'ispremium' => ($account['premdays'] > 0) ? true : false,
'premiumuntil' => time() + ($account['premdays'] * 86400),
'status' => 'active'
),
'playdata' => array(
@ -241,13 +239,7 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
'externalport' => $gameserver['port'],
'previewstate' => 0,
'location' => 'ALL',
// 0 - open pvp
// 1 - optional
// 2 - hardcore
// 3 - retro open pvp
// 4 - retro hardcore pvp
// 5 and higher - (unknown)
'pvptype' => 0,
'pvptype' => 'pvp',
'externaladdressunprotected' => $gameserver['ip'],
'externaladdressprotected' => $gameserver['ip'],
'externalportunprotected' => $gameserver['port'],

View File

@ -80,11 +80,9 @@ if (empty($_POST) === false) {
if ($_POST['selected'] != 1) {
$errors[] = 'You are only allowed to have an account if you accept the rules.';
}
if ($config['validate_IP'] === true) {
if (validate_ip(getIP()) === false) {
if (validate_ip(getIP()) === false && $config['validate_IP'] === true) {
$errors[] = 'Failed to recognize your IP address. (Not a valid IPv4 address).';
}
}
if (strlen($_POST['flag']) < 1) {
$errors[] = 'Please choose country.';
}

View File

@ -220,7 +220,7 @@ foreach ($shop_list as $key => $offer) {
<tr class="special">
<td><?php echo $offers['description']; ?></td>
<?php if ($config['shop']['showImage']):?>
<td><img src="//<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
<td><img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
<?php endif; ?>
<td><?php echo $offers['count']; ?>x</td>
<td><?php echo $offers['points']; ?></td>
@ -251,7 +251,7 @@ foreach ($shop_list as $key => $offer) {
<tr class="special">
<td><?php echo $offers['description']; ?></td>
<?php if ($config['shop']['showImage']):?>
<td><img src="//<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
<td><img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
<?php endif; ?>
<td><?php echo $offers['count']; ?> Days</td>
<td><?php echo $offers['points']; ?></td>
@ -351,7 +351,7 @@ foreach ($shop_list as $key => $offer) {
<tr class="special">
<td><?php echo $offers['description']; ?></td>
<?php if ($config['shop']['showImage']):?>
<td><img src="//<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
<td><img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
<?php endif;
if ($offers['count'] === 0): ?>
<td>Unlimited</td>