Merge
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Clan;
|
||||
|
||||
use Core\Db;
|
||||
|
||||
class ClanInfo
|
||||
{
|
||||
public static function isJoinable(string $name): bool
|
||||
{
|
||||
return Db::getValue('select count(name) from clan where name = ? and status = 1', [$name]) > 0;
|
||||
}
|
||||
}
|
||||
@@ -11,33 +11,13 @@ class ItemStorage
|
||||
{
|
||||
private string $error = '';
|
||||
|
||||
private function isGoodForStorage(array $item, $userClanId): bool
|
||||
{
|
||||
if (empty($item['inslot']) || !empty($item['gift'])) {
|
||||
$this->error = 'Ïðåäìåò íå íàéäåí.';
|
||||
}
|
||||
$idata = ConversionHelper::dataStringToArray($item['data']);
|
||||
if (
|
||||
!empty($idata['frompisher']) ||
|
||||
!empty($idata['sudba']) ||
|
||||
!empty($idata['icos']) ||
|
||||
!empty($idata['fromlaba'])
|
||||
) {
|
||||
$this->error = 'Ïðåäìåò íå ïîäõîäèò.';
|
||||
}
|
||||
if (!empty($idata['toclan']) && explode('#', $idata['toclan'])[0] == $userClanId) {
|
||||
$this->error = 'Ïðåäìåò óæå ïðèíàäëåæèò êëàíó.';
|
||||
}
|
||||
return empty($this->error);
|
||||
}
|
||||
|
||||
public function put(int $itemId, int $clanId): string
|
||||
{
|
||||
$user = User::start()->info;
|
||||
$item = ItemsModel::getOwnedItemById($itemId, $user['id']);
|
||||
$clanName = Db::getValue('select name from clan where id = ?', [$clanId]) ?? '';
|
||||
if (empty($clanName)) {
|
||||
return 'Êëàí íå íàéäåí.';
|
||||
return 'Клан не найден.';
|
||||
}
|
||||
if (!$this->isGoodForStorage($item, $user['clan'])) {
|
||||
return $this->error;
|
||||
@@ -50,7 +30,7 @@ class ItemStorage
|
||||
User::start()->addDelo(
|
||||
2,
|
||||
$user['id'],
|
||||
'"System.transfer.MONEY": Ïðåäìåò "' . $item['name'] . '" (#id : "' . $itemId . '") (x' . $col . ') áûë ïîæåðòâîâàí êëàíó "' . $clanName . '" (' . $clanId . ').',
|
||||
'"System.transfer.MONEY": Предмет "' . $item['name'] . '" (#id : "' . $itemId . '") (x' . $col . ') был пожертвован клану "' . $clanName . '" (' . $clanId . ').',
|
||||
time(),
|
||||
$user['city'],
|
||||
'System.transfer.clan',
|
||||
@@ -63,16 +43,35 @@ class ItemStorage
|
||||
}
|
||||
Db::sql(
|
||||
'insert into clan_operations (clan, time, type, text, val, uid) values (?,unix_timestamp(),?,?,?,?)',
|
||||
[$clanId, $sendType, $user['login'], $item['name'] . ("x$col Èä: [$itemId]"), $user['id']]
|
||||
[$clanId, $sendType, $user['login'], $item['name'] . ("x$col Ид: [$itemId]"), $user['id']]
|
||||
);
|
||||
Db::sql(
|
||||
'update items_users set lastUPD = unix_timestamp(), uid = ?, data = ? where id = ?',
|
||||
['-21' . $user['clan'], $item['data'], $itemId]
|
||||
);
|
||||
|
||||
return 'Âû ïåðåäàëè ïðåäìåò "' . $item['name'] . '" êëàíó.';
|
||||
return 'Вы передали предмет "' . $item['name'] . '" клану.';
|
||||
}
|
||||
|
||||
private function isGoodForStorage(array $item, $userClanId): bool
|
||||
{
|
||||
if (empty($item['inslot']) || !empty($item['gift'])) {
|
||||
$this->error = 'Предмет не найден.';
|
||||
}
|
||||
$idata = ConversionHelper::dataStringToArray($item['data']);
|
||||
if (
|
||||
!empty($idata['frompisher']) ||
|
||||
!empty($idata['sudba']) ||
|
||||
!empty($idata['icos']) ||
|
||||
!empty($idata['fromlaba'])
|
||||
) {
|
||||
$this->error = 'Предмет не подходит.';
|
||||
}
|
||||
if (!empty($idata['toclan']) && explode('#', $idata['toclan'])[0] == $userClanId) {
|
||||
$this->error = 'Предмет уже принадлежит клану.';
|
||||
}
|
||||
return empty($this->error);
|
||||
}
|
||||
|
||||
public function ungive_itm_cl($id, $user, $cl): string
|
||||
{
|
||||
@@ -86,27 +85,25 @@ class ItemStorage
|
||||
mysql_query('SELECT `id`,`bot`,`clone` FROM `stats` WHERE `id` = "' . $itm_['uid'] . '" LIMIT 1')
|
||||
);
|
||||
if ($user_itm['bot'] > 0 || $user_itm['clone'] > 0 || !isset($user_itm['id'])) {
|
||||
$r = '<font color="#FF0000"><strong>Âû íå ìîæåòå èçüÿòü äàííûé ïðåäìåò, îí íå ïðèíàäëåæèò êëàíó</strong></font><br />';
|
||||
$r = '<font color="#FF0000"><strong>Вы не можете изьять данный предмет, он не принадлежит клану</strong></font><br />';
|
||||
} elseif (isset($itm_['id'])) {
|
||||
|
||||
if ($itm_['inOdet'] != 0) {
|
||||
$o = ', `inOdet` = 0';
|
||||
} else {
|
||||
$o = '';
|
||||
}
|
||||
$r = '<font color="#FF0000"><strong>Âû óñïåøíî èçúÿëè ïðåäìåò "' . $itm_['name'] . '"</strong></font><br />';
|
||||
$col = $this->itemsX(((int)$id));
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time(
|
||||
) . '", "6", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Èä : [' . $id . '] | Ó ïåðñîíàæà : [' . $itm_['uid'] . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time(
|
||||
) . '", `uid` = "-21' . $res['id'] . '" ' . $o . ' WHERE `id` = "' . $id . '" LIMIT 1'
|
||||
);
|
||||
if ($itm_['inOdet'] != 0) {
|
||||
$o = ', `inOdet` = 0';
|
||||
} else {
|
||||
$o = '';
|
||||
}
|
||||
$r = '<font color="#FF0000"><strong>Вы успешно изъяли предмет "' . $itm_['name'] . '"</strong></font><br />';
|
||||
$col = $this->itemsX(((int)$id));
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "6", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] | У персонажа : [' . $itm_['uid'] . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $res['id'] . '" ' . $o . ' WHERE `id` = "' . $id . '" LIMIT 1'
|
||||
);
|
||||
|
||||
} else {
|
||||
$r = '<font color="#FF0000"><strong>Ïðåäìåò íå íàéäåí.</strong></font><br />';
|
||||
$r = '<font color="#FF0000"><strong>Предмет не найден.</strong></font><br />';
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
@@ -126,19 +123,17 @@ class ItemStorage
|
||||
$cls = $cls[1];
|
||||
}
|
||||
|
||||
$col = $this->itemsX(((int)$id));
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time(
|
||||
) . '", "5", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Èä : [' . $id . '] Õîçÿèí : [' . $cls . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time(
|
||||
) . '", `uid` = "' . $user['id'] . '" WHERE `id` = "' . $id . '" LIMIT 1'
|
||||
);
|
||||
$r = '<font color="#FF0000"><strong>Âû óñïåøíî âçÿëè ïðåäìåò "' . $itm_['name'] . '" èç õðàíèëèùà</strong></font><br />';
|
||||
$col = $this->itemsX(((int)$id));
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "5", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] Хозяин : [' . $cls . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '" WHERE `id` = "' . $id . '" LIMIT 1'
|
||||
);
|
||||
$r = '<font color="#FF0000"><strong>Вы успешно взяли предмет "' . $itm_['name'] . '" из хранилища</strong></font><br />';
|
||||
|
||||
} else {
|
||||
$r = '<font color="#FF0000"><strong>Ïðåäìåò íå íàéäåí.</strong></font><br />' . $id;
|
||||
$r = '<font color="#FF0000"><strong>Предмет не найден.</strong></font><br />' . $id;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
@@ -167,12 +162,10 @@ class ItemStorage
|
||||
mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $pl['item_id'] . '"')
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time(
|
||||
) . '", `uid` = "' . $user['id'] . '", `data` = "' . $pl['data'] . '" WHERE `id` = "' . $pl['id'] . '"'
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '", `data` = "' . $pl['data'] . '" WHERE `id` = "' . $pl['id'] . '"'
|
||||
);
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time(
|
||||
) . '", "' . $type . '", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Èä : [' . $pl['id'] . ']", "' . $user['id'] . '")'
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "' . $type . '", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
} elseif ($pl['uid'] == $user['id']) {
|
||||
$col = $this->itemsX(((int)$pl['id']));
|
||||
@@ -180,14 +173,12 @@ class ItemStorage
|
||||
mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $pl['item_id'] . '"')
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time(
|
||||
) . '", `uid` = "-21' . $user['clan'] . '" WHERE `id` = "' . $pl['id'] . '"'
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $user['clan'] . '" WHERE `id` = "' . $pl['id'] . '"'
|
||||
);
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time(
|
||||
) . '", "9", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Èä : [' . $pl['id'] . ']", "' . $user['id'] . '")'
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "9", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace Clan;
|
||||
|
||||
use Core\Config;
|
||||
use Core\Db;
|
||||
use Uploader;
|
||||
|
||||
class Register
|
||||
{
|
||||
const REGISTER_COST_EKR = 50;
|
||||
private string $name;
|
||||
private int $align = 0;
|
||||
private Uploader $logo;
|
||||
private int $newClanId = 0;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (!isset($_POST['newclanname'], $_POST['newclanalign'], $_FILES['newclanlogo'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setName($_POST['newclanname']);
|
||||
$this->setLogo();
|
||||
$this->setAlign(intval($_POST['newclanalign']));
|
||||
$this->new();
|
||||
}
|
||||
|
||||
private function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
private function setLogo()
|
||||
{
|
||||
$this->logo = new Uploader('newclanlogo');
|
||||
$this->logo->setMaxFileSize(.03);
|
||||
$this->logo->setDimensions(24, 15);
|
||||
$this->logo->setExtentions(['gif', 'png']);
|
||||
}
|
||||
|
||||
private function setAlign(int $align)
|
||||
{
|
||||
if (!in_array($align, [0, 1, 3, 7])) {
|
||||
$align = 0;
|
||||
}
|
||||
$this->align = $align;
|
||||
}
|
||||
|
||||
public function new()
|
||||
{
|
||||
if (!$this->hasGoodName()) {
|
||||
return;
|
||||
}
|
||||
$imageId = $this->logo->saveToDb();
|
||||
if (!$imageId) {
|
||||
echo $this->logo::$error;
|
||||
return;
|
||||
}
|
||||
Db::sql('insert into clan (name, align, logo) values (?,?,?)', [$this->name, $this->align, $imageId]);
|
||||
$this->newClanId = Db::lastInsertId();
|
||||
}
|
||||
|
||||
private function hasGoodName(): bool
|
||||
{
|
||||
return Db::getValue('select count(id) from clan where name = ?', [$this->name]) === 0;
|
||||
}
|
||||
|
||||
public static function approve(int $clanId)
|
||||
{
|
||||
Db::sql('update clan set status = 1, time_reg = unix_timestamp() where id = ?', [$clanId]);
|
||||
}
|
||||
|
||||
public static function reject(int $clanId)
|
||||
{
|
||||
Db::sql('delete from clan where id = ?', [$clanId]);
|
||||
}
|
||||
|
||||
public static function printForm(): string
|
||||
{
|
||||
$img = Config::img() . '/i/align';
|
||||
return <<<REGISTERFORM
|
||||
<style>
|
||||
div.regclangrid [type=radio] {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* IMAGE STYLES */
|
||||
div.regclangrid [type=radio] + img {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* CHECKED STYLES */
|
||||
div.regclangrid [type=radio]:checked + img {
|
||||
outline: 1px solid brown;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
div.regclangrid {
|
||||
display: grid;
|
||||
grid-template-columns: 100px auto;
|
||||
}
|
||||
</style>
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
<div class="regclangrid">
|
||||
<div><label for="clanname">Название:</label></div>
|
||||
<div><input name="newclanname" id="clanname"></div>
|
||||
<div><label for="clanlogo">Логотип:</label></div>
|
||||
<div><input type="file" name="newclanlogo" accept="image/*" id="newclanlogo"> размер: 24×15, формат: png или gif, до 30Кб</div>
|
||||
<div>Склонность:</div>
|
||||
<div>
|
||||
<label><input type="radio" name="newclanalign" value="0" checked><img src="$img/align0.gif" alt="none"></label>
|
||||
<label><input type="radio" name="newclanalign" value="1"><img src="$img/align1.gif" alt="light"></label>
|
||||
<label><input type="radio" name="newclanalign" value="3"><img src="$img/align3.gif" alt="dark"></label>
|
||||
<label><input type="radio" name="newclanalign" value="7"><img src="$img/align7.gif" alt="neutral"></label>
|
||||
</div>
|
||||
<div></div>
|
||||
<div><button type="submit">Подать заявку</button></div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
REGISTERFORM;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNewClanId(): int
|
||||
{
|
||||
return $this->newClanId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,9 @@ class ConversionHelper
|
||||
*/
|
||||
public static function dataStringToArray(string $dataString): array
|
||||
{
|
||||
if (mb_substr($dataString, -1) === '|') {
|
||||
$dataString = rtrim($dataString, '|');
|
||||
}
|
||||
$arr = json_decode(str_replace(['=', '|'], ['":', ',"'], '{"' . $dataString . '}'), true);
|
||||
return $arr ?: [];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Core;
|
||||
|
||||
use Exception;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use PDOStatement;
|
||||
@@ -15,22 +14,71 @@ class Db
|
||||
|
||||
/**
|
||||
* DB constructor.
|
||||
* @throws Exception
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
self::$db = Database::pdoinit();
|
||||
} catch (PDOException $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
throw new PDOException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @return int
|
||||
*/
|
||||
public static function exec(string $query): int
|
||||
{
|
||||
self::init();
|
||||
return self::$db->exec($query);
|
||||
}
|
||||
|
||||
private static function init(): void
|
||||
{
|
||||
self::$instance ??= new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?string $name [optional] Name of the sequence object from which the ID should be returned.
|
||||
* @return string
|
||||
*/
|
||||
public static function lastInsertId(?string $name = null): string
|
||||
{
|
||||
self::init();
|
||||
return self::$db->lastInsertId($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return array
|
||||
*/
|
||||
public static function getRows(string $query, array $args = []): array
|
||||
{
|
||||
return self::run($query, $args)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return PDOStatement
|
||||
*/
|
||||
public static function run(string $query, array $args = []): PDOStatement
|
||||
{
|
||||
try {
|
||||
if (!$args) {
|
||||
return self::query($query);
|
||||
}
|
||||
$stmt = self::prepare($query);
|
||||
$stmt->execute($args);
|
||||
return $stmt;
|
||||
} catch (PDOException $e) {
|
||||
throw new PDOException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $stmt
|
||||
* @return PDOStatement
|
||||
@@ -51,64 +99,6 @@ class Db
|
||||
return self::$db->prepare($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @return int
|
||||
*/
|
||||
static public function exec(string $query): int
|
||||
{
|
||||
self::init();
|
||||
return self::$db->exec($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
static public function lastInsertId(): string
|
||||
{
|
||||
self::init();
|
||||
return self::$db->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return PDOStatement
|
||||
*/
|
||||
public static function run(string $query, array $args = []): PDOStatement
|
||||
{
|
||||
try {
|
||||
if (!$args) {
|
||||
return self::query($query);
|
||||
}
|
||||
$stmt = self::prepare($query);
|
||||
$stmt->execute($args);
|
||||
return $stmt;
|
||||
} catch (PDOException $e) {
|
||||
throw new PDOException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getRow(string $query, array $args = [])
|
||||
{
|
||||
return self::run($query, $args)->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return array
|
||||
*/
|
||||
public static function getRows(string $query, array $args = []): array
|
||||
{
|
||||
return self::run($query, $args)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
@@ -123,6 +113,16 @@ class Db
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getRow(string $query, array $args = [])
|
||||
{
|
||||
return self::run($query, $args)->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Core;
|
||||
|
||||
class View
|
||||
{
|
||||
public static function render(string $view, array $arguments = [])
|
||||
{
|
||||
extract($arguments, EXTR_SKIP);
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . "/_incl_data/Views/$view";
|
||||
|
||||
if (is_readable($file)) {
|
||||
require $file;
|
||||
} else {
|
||||
trigger_error("File $file not found!", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ class KnowledgeTempleItem
|
||||
public int $level;
|
||||
|
||||
private int $rowId;
|
||||
|
||||
/**
|
||||
* @param array $item
|
||||
*/
|
||||
@@ -23,7 +24,7 @@ class KnowledgeTempleItem
|
||||
$this->type = intval($item['type']);
|
||||
$this->name = $item['name'];
|
||||
|
||||
// Îáùèé + êîíêðåòíûé.
|
||||
// Общий + конкретный.
|
||||
$itemData = array_merge(
|
||||
ConversionHelper::dataStringToArray(ItemModel::getItemData($this->id)),
|
||||
ConversionHelper::dataStringToArray($item['data']),
|
||||
@@ -35,4 +36,5 @@ class KnowledgeTempleItem
|
||||
{
|
||||
return !empty($this->rowId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace DTO;
|
||||
|
||||
class Present
|
||||
{
|
||||
/** Логин отправителя
|
||||
* @var string
|
||||
*/
|
||||
public string $sender;
|
||||
/** Логин получателя
|
||||
* @var string
|
||||
*/
|
||||
public string $receiver;
|
||||
/** id подарка
|
||||
* @var int
|
||||
*/
|
||||
public int $itemId;
|
||||
/** Заголовок поздравления.
|
||||
* Обычно отображается в инфе персонажа в тултипе.
|
||||
* @var string
|
||||
*/
|
||||
public string $textTitle = '';
|
||||
/** Текст поздравления
|
||||
* Отображается только получателю подарка в инвентаре.
|
||||
* @var string
|
||||
*/
|
||||
public string $text = '';
|
||||
/** Флаг анонимности. Если true, в поле "отправитель" будет "невидимка".
|
||||
* @var bool
|
||||
*/
|
||||
public bool $anonymousSender = false;
|
||||
/** Флаг кланового подарка. Если true, в поле "отправитель" будет имя клана в котором состоит игрок.
|
||||
* @var bool
|
||||
*/
|
||||
public bool $clanSender = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Core\Db;
|
||||
use User\UserIp;
|
||||
|
||||
class Delo
|
||||
{
|
||||
/**
|
||||
* Запись в личное дело персонажа.
|
||||
* @param int $uid
|
||||
* @param string $dop
|
||||
* @param string $text
|
||||
* @param string $from
|
||||
* @param float $moneyOut
|
||||
* @param int $type
|
||||
* @return void
|
||||
*/
|
||||
public static function add(int $type, string $from, int $uid, string $text, float $moneyOut = 0, string $dop = '')
|
||||
{
|
||||
$sql = 'insert into users_delo (uid, dop, time, city, text, login, `delete`, no_right, ip, moneyOut, type) values (?,?,unix_timestamp(),?,?,?,0,?,?,?,?)';
|
||||
Db::sql($sql, [
|
||||
$uid, $dop, 'capitalcity', $text, $from, '', UserIp::get(), $moneyOut, $type,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Core\Db;
|
||||
|
||||
class Images
|
||||
{
|
||||
public static function getSrc(int $id): string
|
||||
{
|
||||
$i = Db::getRow('select mime_type, img from images where id = ?', [$id]);
|
||||
return 'data:' . $i['mime_type'] . ';base64,' . base64_encode($i['img']);
|
||||
}
|
||||
|
||||
public static function getSrcByName(string $name): string
|
||||
{
|
||||
$i = Db::getRow('select mime_type, img from images where id = (select logo from clan where name = ?)', [$name]);
|
||||
return 'data:' . $i['mime_type'] . ';base64,' . base64_encode($i['img']);
|
||||
}
|
||||
|
||||
public static function getJson(int $id)
|
||||
{
|
||||
$stmt = Db::getRow('select mime_type, img from images where id = ?', [$id]);
|
||||
if (!$stmt) {
|
||||
$stmt = [];
|
||||
}
|
||||
return json_encode($stmt);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace Item\Data;
|
||||
|
||||
class Bonuses
|
||||
{
|
||||
private static array $names = [
|
||||
'hpAll' => 'Уровень жизни (HP)',
|
||||
'mpAll' => 'Уровень маны',
|
||||
's1' => 'Сила',
|
||||
's2' => 'Ловкость',
|
||||
's3' => 'Интуиция',
|
||||
's4' => 'Выносливость',
|
||||
's5' => 'Интелект',
|
||||
's6' => 'Мудрость',
|
||||
'm1' => 'Мф. критического удара (%)',
|
||||
'm2' => 'Мф. против критического удара (%)',
|
||||
'm3' => 'Мф. мощности критического удара (%)',
|
||||
'm4' => 'Мф. увертывания (%)',
|
||||
'm5' => 'Мф. против увертывания (%)',
|
||||
'm6' => 'Мф. контрудара (%)',
|
||||
'm7' => 'Мф. парирования (%)',
|
||||
'm8' => 'Мф. блока щитом (%)',
|
||||
'm9' => 'Мф. пробоя брони (%)',
|
||||
'm10' => 'Мф. мощности урона',
|
||||
'm11' => 'Мф. мощности магии стихий',
|
||||
'm14' => 'Мф. абс. критического удара (%)',
|
||||
'm15' => 'Мф. абс. увертывания (%)',
|
||||
'm18' => 'Мф. абс. блока щитом (%)',
|
||||
'a1' => 'Мастерство владения ножами, кинжалами',
|
||||
'a2' => 'Мастерство владения топорами, секирами',
|
||||
'a3' => 'Мастерство владения дубинами, молотами',
|
||||
'a4' => 'Мастерство владения мечами',
|
||||
'a5' => 'Мастерство владения магическими посохами',
|
||||
'aall' => 'Мастерство владения оружием',
|
||||
'mall' => 'Мастерство владения магией стихий',
|
||||
'mg1' => 'Мастерство владения магией огня',
|
||||
'mg2' => 'Мастерство владения магией воздуха',
|
||||
'mg3' => 'Мастерство владения магией воды',
|
||||
'mg4' => 'Мастерство владения магией земли',
|
||||
'mg7' => 'Мастерство владения серой магией',
|
||||
'pa1' => 'Мф. мощности колющего урона',
|
||||
'pa2' => 'Мф. мощности рубящего урона',
|
||||
'pa3' => 'Мф. мощности дробящий урона',
|
||||
'pa4' => 'Мф. мощности режущий урона',
|
||||
'pm1' => 'Мф. мощности магии огня',
|
||||
'pm2' => 'Мф. мощности магии воздуха',
|
||||
'pm3' => 'Мф. мощности магии воды',
|
||||
'pm4' => 'Мф. мощности магии земли',
|
||||
'za' => 'Защита от урона',
|
||||
'zm' => 'Защита от магии стихий',
|
||||
'speedhp' => 'Регенерация здоровья (НР)',
|
||||
'speedmp' => 'Регенерация маны (МР)',
|
||||
'zona' => 'Дополнительная зона атаки',
|
||||
'zonb' => 'Дополнительная зона блока',
|
||||
'speed_dungeon' => 'Скорость перемещения по пещерам',
|
||||
'antm3' => 'Мф. против мощности крит. удара',
|
||||
'spasenie' => 'Спасение после смерти',
|
||||
'exp' => 'Получаемый опыт (%)',
|
||||
'repair_z' => 'Бесплатное извлечение заточек',
|
||||
'repair_r' => 'Бесплатное извлечение рун',
|
||||
'repair_discount' => 'Скидка на ремонт вещей',
|
||||
'gold' => 'Благодать Ангела',
|
||||
'magic_cast' => 'Дополнительное заклинание за ход',
|
||||
];
|
||||
|
||||
private array $result = [];
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
foreach ($data as $bonusName => $value) {
|
||||
if (!self::$names[$bonusName]) {
|
||||
continue;
|
||||
}
|
||||
$this->result[self::$names[$bonusName]] = $value;
|
||||
}
|
||||
$this->armor($data);
|
||||
}
|
||||
|
||||
private function armor(array $data): void
|
||||
{
|
||||
$min = 0;
|
||||
$max = 0;
|
||||
$type = [
|
||||
1 => 'головы',
|
||||
2 => 'корпуса',
|
||||
3 => 'пояса',
|
||||
4 => 'ног',
|
||||
];
|
||||
foreach ($type as $k => $v) {
|
||||
if (!empty($data['mib' . $k])) {
|
||||
$min = $data['mib' . $k];
|
||||
$max = $data['mib' . $k];
|
||||
}
|
||||
if (!empty($data['mab' . $k])) {
|
||||
if (empty($data['mib' . $k])) {
|
||||
$min = $data['mab' . $k];
|
||||
}
|
||||
$max = $data['mab' . $k];
|
||||
}
|
||||
if (empty($min) && empty($max)) {
|
||||
return;
|
||||
}
|
||||
$this->result['Броня ' . $v] = $min . ' - ' . $max;
|
||||
}
|
||||
}
|
||||
|
||||
public function get(): array
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
public function addZonb()
|
||||
{
|
||||
if (isset($this->result[self::$names['zonb']])) {
|
||||
$this->result[self::$names['zonb']]++;
|
||||
} else {
|
||||
$this->result[self::$names['zonb']] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Item\Data;
|
||||
|
||||
class Properties
|
||||
{
|
||||
private static array $names = [
|
||||
'damage' => 'Урон',
|
||||
];
|
||||
private array $result = [];
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->damage($data);
|
||||
}
|
||||
|
||||
private function damage(array $data): void
|
||||
{
|
||||
$min = 0;
|
||||
$max = 0;
|
||||
if (!empty($data['yron_min'])) {
|
||||
$min = $data['yron_min'];
|
||||
$max = $data['yron_min'];
|
||||
}
|
||||
if (!empty($data['yron_max'])) {
|
||||
if (empty($data['yron_min'])) {
|
||||
$min = $data['yron_max'];
|
||||
}
|
||||
$max = $data['yron_max'];
|
||||
}
|
||||
if (empty($min) && empty($max)) {
|
||||
return;
|
||||
}
|
||||
$this->result[self::$names['damage']] = $min . ' - ' . $max;
|
||||
}
|
||||
|
||||
public function get(): array
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Item\Data;
|
||||
|
||||
class Requirements
|
||||
{
|
||||
private static array $names = [
|
||||
'sex' => 'Пол',
|
||||
'lvl' => 'Уровень',
|
||||
's1' => 'Сила',
|
||||
's2' => 'Ловкость',
|
||||
's3' => 'Интуиция',
|
||||
's4' => 'Выносливость',
|
||||
's5' => 'Интелект',
|
||||
's6' => 'Мудрость',
|
||||
'a1' => 'Мастерство владения ножами, кинжалами',
|
||||
'a2' => 'Мастерство владения топорами, секирами',
|
||||
'a3' => 'Мастерство владения дубинами, молотами',
|
||||
'a4' => 'Мастерство владения мечами',
|
||||
'a5' => 'Мастерство владения магическими посохами',
|
||||
'mg1' => 'Мастерство владения магией огня',
|
||||
'mg2' => 'Мастерство владения магией воздуха',
|
||||
'mg3' => 'Мастерство владения магией воды',
|
||||
'mg4' => 'Мастерство владения магией земли',
|
||||
'mg7' => 'Мастерство владения серой магией',
|
||||
'align' => 'Склонность',
|
||||
];
|
||||
private static array $sex = [
|
||||
0 => 'Мужской',
|
||||
1 => 'Женский',
|
||||
];
|
||||
private static array $align = [
|
||||
1 => 'Свет',
|
||||
2 => 'Хаос',
|
||||
3 => 'Тьма',
|
||||
7 => 'Нейстралитет',
|
||||
9 => 'Дитя подземелья',
|
||||
];
|
||||
private int $alignValue = 0;
|
||||
|
||||
private array $result = [];
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
foreach ($data as $requirementName => $value) {
|
||||
if (!self::$names[$requirementName]) {
|
||||
continue;
|
||||
}
|
||||
if ($requirementName === 'sex') {
|
||||
if (self::$sex[$value]) {
|
||||
$value = self::$sex[$value];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ($requirementName === 'align') {
|
||||
if (self::$align[$value]) {
|
||||
$this->alignValue = $value;
|
||||
$value = self::$align[$value];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$this->result[$requirementName] = [
|
||||
'name' => self::$names[$requirementName],
|
||||
'value' => $value,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function get(): array
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
/** Число для отрисовки иконки.
|
||||
* @return int
|
||||
*/
|
||||
public function getAlign(): int
|
||||
{
|
||||
return $this->alignValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Item;
|
||||
|
||||
use Core\ConversionHelper;
|
||||
use Core\Db;
|
||||
|
||||
class DataModel
|
||||
{
|
||||
private array $data = [];
|
||||
|
||||
public function __construct(int $itemId)
|
||||
{
|
||||
$datastring = Db::getValue('select data from items_main_data where items_id = ?', [$itemId]);
|
||||
if (empty($datastring)) {
|
||||
return;
|
||||
}
|
||||
$this->data = ConversionHelper::dataStringToArray($datastring);
|
||||
}
|
||||
|
||||
public function getAll(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function getRequirements(): array
|
||||
{
|
||||
return $this->getPrefixed('tr_');
|
||||
}
|
||||
|
||||
private function getPrefixed(string $prefix): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($this->data as $k => $v) {
|
||||
if ($this->searchByPrefix($prefix, $k)) {
|
||||
$result[str_replace($prefix, '', $k)] = $v;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function searchByPrefix(string $prefix, string $string): bool
|
||||
{
|
||||
return substr($string, 0, strlen($prefix)) === $prefix;
|
||||
}
|
||||
|
||||
public function getBonuses(): array
|
||||
{
|
||||
return $this->getPrefixed('add_');
|
||||
}
|
||||
|
||||
public function getProperties(): array
|
||||
{
|
||||
return $this->getPrefixed('sv_');
|
||||
}
|
||||
}
|
||||
+494
-514
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
use Core\Db;
|
||||
use User\Clan;
|
||||
|
||||
class Present
|
||||
{
|
||||
const EXP_NEEDED_FOR_ADD_PRESENT_TEXT = 500000;
|
||||
private array $sender;
|
||||
private array $receiver;
|
||||
private string $status;
|
||||
private \DTO\Present $present;
|
||||
private Clan $senderClan;
|
||||
|
||||
/**
|
||||
* @param \DTO\Present $present
|
||||
*/
|
||||
public function __construct(\DTO\Present $present)
|
||||
{
|
||||
$check = Db::getValue('select count(id) from users where login in (?,?)', [$present->sender, $present->receiver]);
|
||||
if ($check === 1) {
|
||||
$this->status = 'Очень щедро дарить что-то самому себе 😉';
|
||||
return;
|
||||
}
|
||||
if ($check === 0) {
|
||||
$this->status = 'Ошибка: В городе нет такого персонажа!';
|
||||
return;
|
||||
}
|
||||
$this->sender = User::getInfo($present->sender);
|
||||
$this->receiver = User::getInfo($present->receiver);
|
||||
$this->senderClan = new Clan($this->sender);
|
||||
|
||||
if ($present->anonymousSender) {
|
||||
$this->sender['login'] = 'невидимки';
|
||||
} elseif ($present->clanSender) {
|
||||
$this->sender['login'] = 'клана ' . $this->senderClan->getName();
|
||||
}
|
||||
|
||||
$this->present = $present;
|
||||
|
||||
if ($this->sender['exp'] < self::EXP_NEEDED_FOR_ADD_PRESENT_TEXT) {
|
||||
$this->present->textTitle = '';
|
||||
$this->present->text = '';
|
||||
}
|
||||
|
||||
$this->send();
|
||||
$this->sendResultToChat('Получен подарок от ' . $this->sender['login']);
|
||||
$this->status = 'Подарок был успешно отправлен персонажу ' . $this->receiver['login'];
|
||||
}
|
||||
|
||||
private function send()
|
||||
{
|
||||
$values = [
|
||||
'textTitle' => strip_tags($this->present->textTitle),
|
||||
'text' => strip_tags($this->present->text),
|
||||
'sender' => $this->sender['login'],
|
||||
'receiver' => $this->receiver['id'],
|
||||
'presentId' => $this->present->itemId,
|
||||
];
|
||||
Db::sql('update items_users set gtxt1 = :textTitle, gtxt2 = :text, gift = :sender, time_create = unix_timestamp(), uid = :receiver where id = :presentId', $values);
|
||||
$this->addDelo(['id' => $this->present->itemId, 'name' => (new ItemModel($this->present->itemId))->getName()]);
|
||||
}
|
||||
|
||||
private function addDelo(array $item)
|
||||
{
|
||||
$from = 'present';
|
||||
$senderLog = sprintf('Отправлен подарок к %s [id:%s]. Предмет %s [id:%s].', $this->receiver['login'], $this->receiver['id'], $item['name'], $item['id']);
|
||||
$receiverLog = sprintf('Получен подарок от %s [id:%s]. Предмет %s [id:%s].', $this->sender['login'], $this->sender['id'], $item['name'], $item['id']);
|
||||
Delo::add(1, $from, $this->receiver['id'], $receiverLog);
|
||||
Delo::add(1, $from, $this->sender['id'], $senderLog);
|
||||
}
|
||||
|
||||
private function sendResultToChat(string $text)
|
||||
{
|
||||
$msg = new ChatMessage();
|
||||
$msg->setTo($this->receiver['login']);
|
||||
$msg->setType(6);
|
||||
$msg->setText($text);
|
||||
(new Chat())->sendMsg($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Core\Db;
|
||||
|
||||
/**
|
||||
* Единая функция для заливки файлов на сервер.
|
||||
*
|
||||
* @author Ivor Barhansky <me@lopar.space>
|
||||
* @version 1
|
||||
*/
|
||||
|
||||
class Uploader
|
||||
{
|
||||
public static string $error;
|
||||
private array $width = ['min' => 0, 'max' => 0];
|
||||
private array $height = ['min' => 0, 'max' => 0];
|
||||
private int $maxFileSizeMb;
|
||||
private string $savePath;
|
||||
private string $extensions = 'jpg|png|jpeg|gif';
|
||||
private array $extMatches = [];
|
||||
private array $FILE;
|
||||
private $cnm;
|
||||
public static string $error;
|
||||
private array $file;
|
||||
private string $customName;
|
||||
|
||||
public function __construct($name, $cnm = null)
|
||||
public function __construct($name)
|
||||
{
|
||||
if (!isset($_FILES[$name])) {
|
||||
return;
|
||||
}
|
||||
$this->FILE = $_FILES[$name];
|
||||
$this->cnm = $cnm;
|
||||
$this->file = $_FILES[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $max
|
||||
* @param int|null $min
|
||||
* @return void
|
||||
* @param string $customName
|
||||
*/
|
||||
public function setWidth(int $max, ?int $min = null)
|
||||
public function setCustomName(string $customName): void
|
||||
{
|
||||
$this->width['min'] = is_null($min) ? $max : $min;
|
||||
$this->width['max'] = $max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $max
|
||||
* @param int|null $min
|
||||
* @return void
|
||||
*/
|
||||
public function setHeight(int $max, ?int $min = null)
|
||||
{
|
||||
$this->height['min'] = is_null($min) ? $max : $min;
|
||||
$this->height['max'] = $max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $megabytes
|
||||
* @return void
|
||||
*/
|
||||
public function setMaxFileSize($megabytes)
|
||||
{
|
||||
$this->maxFileSizeMb = $megabytes;
|
||||
$this->customName = $customName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,9 +73,48 @@ class Uploader
|
||||
$this->setHeight($height);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $max
|
||||
* @param int|null $min
|
||||
* @return void
|
||||
*/
|
||||
public function setWidth(int $max, ?int $min = null)
|
||||
{
|
||||
$this->width['min'] = is_null($min) ? $max : $min;
|
||||
$this->width['max'] = $max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $max
|
||||
* @param int|null $min
|
||||
* @return void
|
||||
*/
|
||||
public function setHeight(int $max, ?int $min = null)
|
||||
{
|
||||
$this->height['min'] = is_null($min) ? $max : $min;
|
||||
$this->height['max'] = $max;
|
||||
}
|
||||
|
||||
public function saveimg()
|
||||
{
|
||||
return $this->hasNormalFilePath() &&
|
||||
$this->hasNormalDimensions() &&
|
||||
$this->hasNormalFileSize() &&
|
||||
$this->hasNormalType() ? $this->upload() : false;
|
||||
}
|
||||
|
||||
private function hasNormalFilePath(): bool
|
||||
{
|
||||
if (!$this->savePath || !is_dir($this->savePath)) {
|
||||
self::$error = 'Ошибка загрузки: нет такой папки.';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function hasNormalDimensions(): bool
|
||||
{
|
||||
[$width, $height] = getimagesize($this->FILE['tmp_name']);
|
||||
[$width, $height] = getimagesize($this->file['tmp_name']);
|
||||
if (!$width || !$height) {
|
||||
self::$error = 'Не подтянулись размеры файла.';
|
||||
return false;
|
||||
@@ -123,18 +139,27 @@ class Uploader
|
||||
if (!$this->maxFileSizeMb) {
|
||||
$this->setMaxFileSize(2);
|
||||
}
|
||||
if ($this->FILE['size'] > $this->maxFileSizeMb * (1024 * 1024) || $this->FILE['size'] <= 0) {
|
||||
if ($this->file['size'] > $this->maxFileSizeMb * (1024 * 1024) || $this->file['size'] <= 0) {
|
||||
self::$error = 'Неверный размер файла. Максимальный размер файла ' . $this->maxFileSizeMb . ' МБ';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $megabytes
|
||||
* @return void
|
||||
*/
|
||||
public function setMaxFileSize($megabytes)
|
||||
{
|
||||
$this->maxFileSizeMb = $megabytes;
|
||||
}
|
||||
|
||||
private function hasNormalType(): bool
|
||||
{
|
||||
if (
|
||||
!preg_match('/\.(' . $this->extensions . ')$/i', $this->FILE['name'], $this->extMatches) ||
|
||||
!preg_match('/image/i', $this->FILE['type'])
|
||||
!preg_match('/\.(' . $this->extensions . ')$/i', $this->file['name'], $this->extMatches) ||
|
||||
!preg_match('/image/i', $this->file['type'])
|
||||
) {
|
||||
self::$error = 'Неверный тип файла. Допустимые типы : ' . $this->extensions;
|
||||
return false;
|
||||
@@ -142,36 +167,34 @@ class Uploader
|
||||
return true;
|
||||
}
|
||||
|
||||
private function hasNormalFilePath(): bool
|
||||
{
|
||||
if (!$this->savePath || !is_dir($this->savePath)) {
|
||||
self::$error = 'Ошибка загрузки: нет такой папки.';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function upload()
|
||||
{
|
||||
$this->extMatches[1] = strtolower($this->extMatches[1]);
|
||||
$fn = uniqid('f_', true) . '.' . $this->extMatches[1];
|
||||
$fn2 = uniqid('f_', true) . '.gif';
|
||||
if ($this->cnm) {
|
||||
$fn = $this->cnm;
|
||||
$fn2 = $this->cnm;
|
||||
if ($this->customName) {
|
||||
$fn = $this->customName . '.' . pathinfo($this->file['name'], PATHINFO_EXTENSION);
|
||||
$fn2 = $this->customName;
|
||||
}
|
||||
if (!move_uploaded_file($this->FILE['tmp_name'], $this->savePath . $fn)) {
|
||||
if (!move_uploaded_file($this->file['tmp_name'], $this->savePath . $fn)) {
|
||||
self::$error = 'Ошибка загрузки файла';
|
||||
return false;
|
||||
}
|
||||
var_dump([$fn2, $fn, $this->savePath . $fn]);
|
||||
return [$fn2, $fn, $this->savePath . $fn];
|
||||
}
|
||||
|
||||
public function saveimg()
|
||||
public function saveToDb()
|
||||
{
|
||||
return $this->hasNormalFilePath() &&
|
||||
$this->hasNormalDimensions() &&
|
||||
return $this->hasNormalDimensions() &&
|
||||
$this->hasNormalFileSize() &&
|
||||
$this->hasNormalType() ? $this->upload() : false;
|
||||
$this->hasNormalType() ? $this->uploadToDatabase() : false;
|
||||
}
|
||||
}
|
||||
|
||||
private function uploadToDatabase(): int
|
||||
{
|
||||
$id = time();
|
||||
Db::sql('insert into images (mime_type, img, id) VALUES (?,?,?)', [$this->file['type'], file_get_contents($this->file['tmp_name']), $id]);
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
|
||||
+6999
-8045
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace User;
|
||||
|
||||
use Clan\ClanInfo;
|
||||
use Core\Config;
|
||||
use Core\Db;
|
||||
use Images;
|
||||
|
||||
class Clan
|
||||
{
|
||||
private $userid;
|
||||
private int $id = 0;
|
||||
private ?string $name;
|
||||
private ?int $align;
|
||||
private ?int $logo;
|
||||
private ?int $status;
|
||||
|
||||
public function __construct(array $userinfo)
|
||||
{
|
||||
$this->userid = $userinfo['id'];
|
||||
if (isset($_POST['joinclan']) && ClanInfo::isJoinable($_POST['joinclan'])) {
|
||||
$this->join($_POST['joinclan']);
|
||||
exit('<script>window.location.replace("/main.php?clan=1");</script>');
|
||||
}
|
||||
$c = Db::getRow('select * from clan where id = ?', [$userinfo['clan']]);
|
||||
if (!empty($c)) {
|
||||
foreach ($c as $k => $v) {
|
||||
$this->$k = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function join(string $clanname)
|
||||
{
|
||||
Db::sql('update users set clan = (select id from clan where clan.name = ?) where id = ?', [$clanname, $this->userid]);
|
||||
}
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getStatus(): ?int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function printClan()
|
||||
{
|
||||
echo '<img style="vertical-align:text-bottom;" src="' . Config::img() . '/i/align/align' . $this->getAlign() . '.gif" alt="Склонность">' . $this->printLogoImage() . $this->getName();
|
||||
}
|
||||
|
||||
public function getAlign(): ?int
|
||||
{
|
||||
return $this->align;
|
||||
}
|
||||
|
||||
public function printLogoImage(): string
|
||||
{
|
||||
return '<img style="vertical-align:text-bottom;" src = "' . Images::getSrc($this->logo) . '" width = "24px" height = "15px">';
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getLogo(): ?int
|
||||
{
|
||||
return $this->logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Клан зарегистрирован и подверждён.
|
||||
* @return bool
|
||||
*/
|
||||
public function isRegistered(): bool
|
||||
{
|
||||
return !empty($this->id) && $this->status !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Клан зарегистрирован и ожидает подтверждения.
|
||||
* @return bool
|
||||
*/
|
||||
public function isAwaitingConfirmation(): bool
|
||||
{
|
||||
return !empty($this->id) && $this->status === 0;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace User;
|
||||
|
||||
use Core\ConversionHelper;
|
||||
use Core\Db;
|
||||
use Delo;
|
||||
use User;
|
||||
|
||||
class ItemsModel
|
||||
@@ -101,24 +102,18 @@ class ItemsModel
|
||||
if ($mxiznos > 0) {
|
||||
$i['iznosMAXi'] = $mxiznos;
|
||||
}
|
||||
if ($user->info['dnow'] > 0) {
|
||||
$room = $user->room['city'];
|
||||
} else {
|
||||
$room = $user->info['city'];
|
||||
}
|
||||
|
||||
$args = [
|
||||
$i['overTypei'] ?? 0,
|
||||
$i['id'],
|
||||
$uid,
|
||||
$data,
|
||||
$i['iznosMAXi'],
|
||||
$i['geni'],
|
||||
$i['magic_inci'],
|
||||
$room,
|
||||
$i['dn_delete'] ?? 0,
|
||||
];
|
||||
Db::sql(
|
||||
'insert into items_users (overType, item_id, uid, data, iznosMAX, geniration, magic_inc, maidin, lastUPD, time_create, dn_delete) values (?,?,?,?,?,?,?,?,unix_timestamp(),unix_timestamp(),?)',
|
||||
'insert into items_users (overType, item_id, uid, data, iznosMAX, magic_inc, lastUPD, time_create, dn_delete) values (?,?,?,?,?,?,unix_timestamp(),unix_timestamp(),?)',
|
||||
$args
|
||||
);
|
||||
$rt = Db::lastInsertId() ?? 0;
|
||||
@@ -132,16 +127,7 @@ class ItemsModel
|
||||
$ads = 'Расплавлен предмет : [' . $plavka . ']';
|
||||
}
|
||||
//Записываем в личное дело что предмет получен
|
||||
$user->addDelo(
|
||||
1,
|
||||
$uid,
|
||||
'"AddItems.' . $user->info['city'] . '": Получен предмет "<strong>' . $i['name'] . '</strong>" (x1) [#' . $i['iid'] . ']. ' . $ads,
|
||||
time(),
|
||||
$user->info['city'],
|
||||
'AddItems.' . $user->info['city'],
|
||||
0,
|
||||
0
|
||||
);
|
||||
Delo::add(1, 'additems', $uid, 'Получен предмет «' . $i['name'] . '» [id:' . $i['iid'] . ']' . $ads);
|
||||
}
|
||||
}
|
||||
return $rt;
|
||||
|
||||
@@ -1,84 +1,76 @@
|
||||
<?php
|
||||
if(!defined('GAME'))
|
||||
{
|
||||
die();
|
||||
if (!defined('GAME')) {
|
||||
die();
|
||||
}
|
||||
|
||||
if( $itm['magic_inci'] == 'arhmoney' ) {
|
||||
if( $u->info['inTurnir'] == 0 ) {
|
||||
$u->error = 'Необходимо участвовать в турнире Башни Смерти';
|
||||
}else{
|
||||
$noarh = true;
|
||||
$bsd = mysql_fetch_array(mysql_query('SELECT `id`,`users`,`arhiv`,`count`,`city`,`money` FROM `bs_turnirs` WHERE `id` = "'.$u->info['inTurnir'].'" LIMIT 1'));
|
||||
if( isset($bsd['id']) ) {
|
||||
$bsd_arh = mysql_fetch_array(mysql_query('SELECT `u`.`id`,`u`.`battle`,`s`.`x`,`s`.`y` FROM `users` AS `u` LEFT JOIN `stats` AS `s` ON `s`.`id` = `u`.`id` WHERE `u`.`inTurnir` = "'.$u->info['inTurnir'].'" AND `u`.`login` = "Архивариус" AND `u`.`pass` = "bstowerbot" LIMIT 1'));
|
||||
if( $bsd['users'] > 1 && $noarh == false && true == false ) {
|
||||
$u->error = 'Вы должны остаться единственным участником Башни Смерти';
|
||||
}else{
|
||||
if( $u->info['inUser'] == 0 ) {
|
||||
$usr_tk = mysql_fetch_array(mysql_query('SELECT `level`,`id`,`money`,`login`,`align`,`clan`,`sex` FROM `users` WHERE `inUser` = "'.$u->info['id'].'" LIMIT 1'));
|
||||
if( isset($usr_tk['id']) ) {
|
||||
if( $itm['price2'] > 0 ) {
|
||||
$bnki = mysql_fetch_array(mysql_query('SELECT * FROM `bank` WHERE `uid` = "'.$usr_tk['id'].'" AND `block` = "0" ORDER BY `id` DESC LIMIT 1'));
|
||||
}
|
||||
if( $itm['price2'] == 0 ) {
|
||||
mysql_query('UPDATE `users` SET `money` = `money` + "'.$itm['price1'].'" WHERE `inUser` = "'.$u->info['id'].'" LIMIT 1');
|
||||
}else{
|
||||
mysql_query('UPDATE `bank` SET `money2` = `money2` + "'.$itm['price2'].'" WHERE `id` = "'.$bnki['id'].'" LIMIT 1');
|
||||
}
|
||||
mysql_query('UPDATE `items_users` SET `iznosNOW` = `iznosNOW` + 1 WHERE `id` = '.$itm['id'].' LIMIT 1');
|
||||
if( $itm['price2'] == 0 ) {
|
||||
$u->error = 'Вы успешно обналичил чек на '.$itm['price1'].' кр.';
|
||||
}else{
|
||||
if( isset($bnki['id']) ) {
|
||||
$u->error = 'Вы успешно обналичил чек на '.$itm['price2'].' екр. (Банк: №'.$bnki['id'].' )';
|
||||
}else{
|
||||
$u->error = 'Чек на '.$itm['price2'].' екр. был обналичен, но у Вас нет подходящего банковского счета! Деньги сгорели!';
|
||||
}
|
||||
}
|
||||
//Добавляем в лог БС
|
||||
if( $itm['price2'] == 0 ) {
|
||||
if( $u->info['sex'] == 0 ) {
|
||||
$text = '{u1} обналичил чек на <b>'.$itm['price1'].' кр.</b>';
|
||||
}else{
|
||||
$text = '{u1} обналичила чек на <b>'.$itm['price1'].' кр.</b>';
|
||||
}
|
||||
}else{
|
||||
if( $u->info['sex'] == 0 ) {
|
||||
$text = '{u1} обналичил чек на <b>'.$itm['price2'].' екр.</b>';
|
||||
}else{
|
||||
$text = '{u1} обналичила чек на <b>'.$itm['price2'].' екр.</b>';
|
||||
}
|
||||
}
|
||||
if( isset($usr_tk['id']) ) {
|
||||
$mereal = '';
|
||||
if( $usr_tk['align'] > 0 ) {
|
||||
$mereal .= '<img src=//img.new-combats.tech/i/align/align'.$usr_tk['align'].'.gif width=12 height=15 >';
|
||||
}
|
||||
if( $usr_tk['clan'] > 0 ) {
|
||||
$mereal .= '<img src=//img.new-combats.tech/i/clan/'.$usr_tk['clan'].'.gif width=24 height=15 >';
|
||||
}
|
||||
$mereal .= '<b>'.$usr_tk['login'].'</b> ['.$usr_tk['level'].']<a target=_blank href=/info/'.$usr_tk['id'].' ><img width=12 hiehgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
|
||||
}else{
|
||||
$mereal = '<i>Невидимка</i>[??]';
|
||||
}
|
||||
$text = str_replace('{u1}',$mereal,$text);
|
||||
//Добавляем в лог БС
|
||||
mysql_query('INSERT INTO `bs_logs` (`type`,`text`,`time`,`id_bs`,`count_bs`,`city`,`m`,`u`) VALUES (
|
||||
"1", "'.mysql_real_escape_string($text).'", "'.time().'", "'.$bsd['id'].'", "'.$bsd['count'].'", "'.$bsd['city'].'",
|
||||
"'.round($bsd['money']*0.85,2).'","'.$i.'"
|
||||
if ($itm['magic_inci'] == 'arhmoney') {
|
||||
if ($u->info['inTurnir'] == 0) {
|
||||
$u->error = 'Необходимо участвовать в турнире Башни Смерти';
|
||||
} else {
|
||||
$noarh = true;
|
||||
$bsd = mysql_fetch_array(mysql_query('SELECT `id`,`users`,`arhiv`,`count`,`city`,`money` FROM `bs_turnirs` WHERE `id` = "' . $u->info['inTurnir'] . '" LIMIT 1'));
|
||||
if (isset($bsd['id'])) {
|
||||
$bsd_arh = mysql_fetch_array(mysql_query('SELECT `u`.`id`,`u`.`battle`,`s`.`x`,`s`.`y` FROM `users` AS `u` LEFT JOIN `stats` AS `s` ON `s`.`id` = `u`.`id` WHERE `u`.`inTurnir` = "' . $u->info['inTurnir'] . '" AND `u`.`login` = "Архивариус" AND `u`.`pass` = "bstowerbot" LIMIT 1'));
|
||||
if ($bsd['users'] > 1 && $noarh == false && true == false) {
|
||||
$u->error = 'Вы должны остаться единственным участником Башни Смерти';
|
||||
} else {
|
||||
if ($u->info['inUser'] == 0) {
|
||||
$usr_tk = mysql_fetch_array(mysql_query('SELECT `level`,`id`,`money`,`login`,`align`,`clan`,`sex` FROM `users` WHERE `inUser` = "' . $u->info['id'] . '" LIMIT 1'));
|
||||
if (isset($usr_tk['id'])) {
|
||||
if ($itm['price2'] == 0) {
|
||||
$u->addKr($itm['price1']);
|
||||
} else {
|
||||
$u->addEkr($itm['price2'], $usr_tk['id']);
|
||||
}
|
||||
mysql_query('UPDATE `items_users` SET `iznosNOW` = `iznosNOW` + 1 WHERE `id` = ' . $itm['id'] . ' LIMIT 1');
|
||||
if ($itm['price2'] == 0) {
|
||||
$u->error = 'Вы успешно обналичил чек на ' . $itm['price1'] . ' кр.';
|
||||
} else {
|
||||
$u->error = 'Вы успешно обналичил чек на ' . $itm['price2'] . ' екр.';
|
||||
}
|
||||
//Добавляем в лог БС
|
||||
if ($itm['price2'] == 0) {
|
||||
if ($u->info['sex'] == 0) {
|
||||
$text = '{u1} обналичил чек на <b>' . $itm['price1'] . ' кр.</b>';
|
||||
} else {
|
||||
$text = '{u1} обналичила чек на <b>' . $itm['price1'] . ' кр.</b>';
|
||||
}
|
||||
} else {
|
||||
if ($u->info['sex'] == 0) {
|
||||
$text = '{u1} обналичил чек на <b>' . $itm['price2'] . ' екр.</b>';
|
||||
} else {
|
||||
$text = '{u1} обналичила чек на <b>' . $itm['price2'] . ' екр.</b>';
|
||||
}
|
||||
}
|
||||
if (isset($usr_tk['id'])) {
|
||||
$mereal = '';
|
||||
if ($usr_tk['align'] > 0) {
|
||||
$mereal .= '<img src=//img.new-combats.tech/i/align/align' . $usr_tk['align'] . '.gif width=12 height=15 >';
|
||||
}
|
||||
if ($usr_tk['clan'] > 0) {
|
||||
$mereal .= '<img src=//img.new-combats.tech/i/clan/' . $usr_tk['clan'] . '.gif width=24 height=15 >';
|
||||
}
|
||||
$mereal .= '<b>' . $usr_tk['login'] . '</b> [' . $usr_tk['level'] . ']<a target=_blank href=/info/' . $usr_tk['id'] . ' ><img width=12 hiehgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
|
||||
} else {
|
||||
$mereal = '<i>Невидимка</i>[??]';
|
||||
}
|
||||
$text = str_replace('{u1}', $mereal, $text);
|
||||
//Добавляем в лог БС
|
||||
mysql_query('INSERT INTO `bs_logs` (`type`,`text`,`time`,`id_bs`,`count_bs`,`city`,`m`,`u`) VALUES (
|
||||
"1", "' . mysql_real_escape_string($text) . '", "' . time() . '", "' . $bsd['id'] . '", "' . $bsd['count'] . '", "' . $bsd['city'] . '",
|
||||
"' . round($bsd['money'] * 0.85, 2) . '","' . $i . '"
|
||||
)');
|
||||
//
|
||||
}else{
|
||||
$u->error = 'Что-то здесь не так...';
|
||||
}
|
||||
}else{
|
||||
$u->error = 'Вы должны участвовать в турнире Башни Смерти';
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$u->error = 'Необходимо участвовать в турнире Башни Смерти';
|
||||
}
|
||||
}
|
||||
//
|
||||
} else {
|
||||
$u->error = 'Что-то здесь не так...';
|
||||
}
|
||||
} else {
|
||||
$u->error = 'Вы должны участвовать в турнире Башни Смерти';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$u->error = 'Необходимо участвовать в турнире Башни Смерти';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
if(!defined('GAME'))
|
||||
{
|
||||
die();
|
||||
}
|
||||
|
||||
//удаляем предмет (1 из кучи) , а так-же добавляем + 1 к репутации
|
||||
if($u->info['room'] == 322) {
|
||||
$u->deleteItem($itm['id']);
|
||||
mysql_query('UPDATE `rep` SET `rep2` = `rep2` + 1 WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
|
||||
$u->error = 'Вы успешно использовали "'.$itm['name'].'"...';
|
||||
}else{
|
||||
$u->error = 'Нельзя использовать в этой локации...';
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user