mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-18 19:53:27 +02:00
Merge branch 'develop' into feature/settings
This commit is contained in:
@@ -63,6 +63,16 @@ class DataLoader
|
||||
|
||||
self::$startTime = microtime(true);
|
||||
|
||||
require_once LIBS . 'npc.php';
|
||||
if(NPCs::loadFromXML()) {
|
||||
success(self::$locale['step_database_loaded_npcs'] . self::getLoadedTime());
|
||||
}
|
||||
else {
|
||||
error(self::$locale['step_database_error_npcs']);
|
||||
}
|
||||
|
||||
self::$startTime = microtime(true);
|
||||
|
||||
require LIBS . 'spells.php';
|
||||
if(Spells::loadFromXML()) {
|
||||
success(self::$locale['step_database_loaded_spells'] . self::getLoadedTime());
|
||||
@@ -100,4 +110,4 @@ class DataLoader
|
||||
$endTime = round(microtime(true) - self::$startTime, 3);
|
||||
return ' (' . str_replace('$TIME$', $endTime, self::$locale['loaded_in_ms']) . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
59
system/libs/npc.php
Normal file
59
system/libs/npc.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* NPC class
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @author Lee
|
||||
* @copyright 2021 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class NPCs
|
||||
{
|
||||
public static $npcs;
|
||||
|
||||
public static function loadFromXML($show = false)
|
||||
{
|
||||
$npc_path = config('data_path') . 'npc/';
|
||||
if (!file_exists($npc_path))
|
||||
return false;
|
||||
|
||||
$npcs = [];
|
||||
$xml = new DOMDocument();
|
||||
foreach (preg_grep('~\.(xml)$~i', scandir($npc_path)) as $npc) {
|
||||
$xml->load($npc_path . $npc);
|
||||
if ($xml) {
|
||||
$element = $xml->getElementsByTagName('npc')->item(0);
|
||||
if (isset($element)) {
|
||||
$name = $element->getAttribute('name');
|
||||
if (!empty($name) && !in_array($name, $npcs)) {
|
||||
$npcs[] = strtolower($name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($npcs) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once LIBS . 'cache_php.php';
|
||||
$cache_php = new Cache_PHP(config('cache_prefix'), CACHE);
|
||||
$cache_php->set('npcs', $npcs, 5 * 365 * 24 * 60 * 60);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function load()
|
||||
{
|
||||
if (self::$npcs) {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once LIBS . 'cache_php.php';
|
||||
$cache_php = new Cache_PHP(config('cache_prefix'), CACHE);
|
||||
self::$npcs = $cache_php->get('npcs');
|
||||
}
|
||||
}
|
@@ -42,6 +42,8 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
private $data = array('email' => '', 'blocked' => false, 'rlname' => '','location' => '', 'country' => '','web_flags' => 0, 'lastday' => 0, 'premdays' => 0, 'created' => 0);
|
||||
|
||||
public static $cache = array();
|
||||
|
||||
const GRATIS_PREMIUM_DAYS = 65535;
|
||||
/**
|
||||
* Creates new account.
|
||||
*
|
||||
@@ -382,6 +384,10 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
global $config;
|
||||
if(isset($config['lua']['freePremium']) && getBoolean($config['lua']['freePremium'])) return -1;
|
||||
|
||||
if($this->data['premdays'] == self::GRATIS_PREMIUM_DAYS){
|
||||
return self::GRATIS_PREMIUM_DAYS;
|
||||
}
|
||||
|
||||
$ret = ceil($this->data['premdays'] - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->data['lastday']))) - date("z", $this->data['lastday'])));
|
||||
return $ret > 0 ? $ret : 0;
|
||||
}
|
||||
|
@@ -221,6 +221,16 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
$npcCheck = config('character_name_npc_check');
|
||||
if ($npcCheck) {
|
||||
require_once LIBS . 'npc.php';
|
||||
NPCS::load();
|
||||
if(NPCS::$npcs && in_array(strtolower($name), NPCS::$npcs)) {
|
||||
self::$lastError = "Invalid name format. Do not use NPC Names";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -334,6 +344,16 @@ class Validator
|
||||
}
|
||||
}
|
||||
|
||||
$npcCheck = config('character_name_npc_check');
|
||||
if ($npcCheck) {
|
||||
require_once LIBS . 'npc.php';
|
||||
NPCS::load();
|
||||
if(NPCS::$npcs && in_array($name_lower, NPCS::$npcs)) {
|
||||
self::$lastError = "Invalid name format. Do not use NPC Names";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '") != $name_length) {
|
||||
self::$lastError = 'This name contains invalid letters, words or format. Please use only a-Z, - , \' and space.';
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user