AntiBK/engline/functions/class_Bank.php
Ivor Barhansky 36bf662112 code-upload (#1)
Upload code

Изменил(а) на 'README.md'

Изменил(а) на 'README.md'

Reviewed-on: https://src.lopar.us/lopar/AntiBK/pulls/1
Co-Authored-By: Ivor Barhansky <lopar@noreply.lopar.us>
Co-Committed-By: Ivor Barhansky <lopar@noreply.lopar.us>
2021-02-11 16:13:04 +00:00

74 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?
defined('AntiBK') or die("Доступ запрещен!");
class Bank extends Char
{
public $guid;
public $db;
public $char;
function Init ($object)
{
$this->guid = $object->guid;
$this->db = $object->db;
$this->char = $object;
}
/*Начало работы с банковским счетом*/
function Login ($id, $pass)
{
$seek = $this->db->selectRow("SELECT `guid`,
`password`
FROM `character_bank`
WHERE `id` = ?d
and `guid` = ?d", $id ,$this->guid);
if (!$seek)
return 303;
if ($this->guid != $seek['guid'])
return 322;
if (SHA1($id.':'.$pass) != $seek['password'])
return 302;
$_SESSION['bankСredit'] = $id;
return 0;
}
/*Конец работы с банковским счетом*/
function unLogin ()
{
unset($_SESSION['bankСredit']);
}
/*Увеличение/уменьшение денег в банке у персонажа*/
function Money ($sum, $id, $type = '', $guid = 0)
{
if (checki($id) || !is_numeric($sum))
$this->char->error->Map(326);
$sum = rdf($sum);
if ($sum == 0)
$this->char->error->Map(325);
$guid = $this->getGuid($guid);
switch ($type)
{
case 'euro':
$money = $this->db->selectCell("SELECT `euro` FROM `character_bank` WHERE `id` = ?d and `guid` = ?d", $id ,$guid);
if (($money = rdf($money - $sum)) < 0)
$this->char->error->Map(310, $sum);
$this->db->query("UPDATE `character_bank` SET `euro` = ?f WHERE `id` = ?d and `guid` = ?d", $money ,$id ,$guid);
break;
default:
$money = $this->db->selectCell("SELECT `cash` FROM `character_bank` WHERE `id` = ?d and `guid` = ?d", $id ,$guid);
if (($money = rdf($money - $sum)) < 0)
$this->char->error->Map(305, $sum);
$this->db->query("UPDATE `character_bank` SET `cash` = ?f WHERE `id` = ?d and `guid` = ?d", $money ,$id ,$guid);
break;
}
return true;
}
}
?>