Example #1
0
function spendProfileMoney($uuid, $money = 0.0, $reason = "spendProfileMoney")
{
    global $authserver;
    // Профиль существует?
    if (!isProfileExist($uuid)) {
        return false;
    }
    // Денег достаточно?
    $available = getProfileMoney($uuid);
    if ($available === false || $available < $money) {
        return false;
    }
    // Снять!
    $query = "UPDATE `authserver`.`account_money` SET `money` = `money` - '{$money}' WHERE `udid` = '{$uuid}';";
    $authserver->query($query) or responseWithError("InternalDatabaseError", $authserver->error);
    // Записать в лог
    writeMoneyLog($uuid, -$money, $reason);
    return true;
}
Example #2
0
if (isset($notification['test_notification']) && $notification['test_notification'] == 'true') {
    $isTest = true;
    // die('TEST-OK');
}
// Кошелёк может быть переполнен и не принимать переводы
if (isset($notification['unaccepted']) && $notification['unaccepted'] == 'true') {
    die('METHOD TEMPORARY UNAVAILABLE');
}
// Не стоит принимать отрицательные переводы :)
$money = doubleval($notification['amount']);
if ($money <= 0.0) {
    responseWithError("Parameters are incorrect (3)");
}
$log = "Яндекс.Деньги: Принят платёж от " . $notification['sender'] . " в размере {$money} рублей.";
// В поле label мы храним uuid пополняемой учётной записи
$uuid = null;
if (isset($notification['label'])) {
    $uuid = $notification['label'];
    if (!isProfileExist($uuid)) {
        echo 'UUID IS NOT SET!\\n';
    } else {
        if (!$isTest) {
            // Приём денежных средств на указанный счёт
            addProfileMoney($uuid, $money, $log);
            die('OK');
        }
    }
}
// Записываем приём в лог
writeAccountLog(null, $log);
die('OK');
<?php

/*
 * https://auth.methuselah.ru/toolbox/allNames.php
 */
define('METHUSELAH_INCLUDE_CHECK', true);
require_once "toolbox_internal.php";
$uuid = filter_input(INPUT_GET, 'uuid', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH) or responseWithError("Profile is not specified", "Good bye.");
$skin = filter_input(INPUT_GET, 'skin', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH) or responseWithError("Skin URL is not specified", "Good bye.");
if (isProfileExist($uuid) && !isProfileGuest($uuid)) {
    setProfileClothesSkin($uuid, $skin, false);
    response();
}
responseWithError("Profile doesn't not exist");
function getProfile($uuid, $includeProps = false)
{
    if (isProfileExist($uuid)) {
        $name = getProfileName($uuid);
        $response = array("id" => $uuid, "name" => $name);
        if (isProfileGuest($uuid)) {
            $response['guest'] = true;
        }
        if ($includeProps) {
            $response['properties'] = getProfileProps($uuid, $name);
        }
        return $response;
    }
    return false;
}