<?
require '../_system/core.php';

$_API = $_GET['page'];

function getUser($id) {
    global $sql;
    $user = $sql->fetch("SELECT `id`, `login`, `family`, `name`, `wmid`, `wmr`, `purse`, `icq`, `skype` FROM `users` WHERE `id` = '" . ((int) $id) . "' LIMIT 1");
    $user['link'] = 'http://4i4i.ru/wm/' . $user['login'];
    return $user;
}

// json :: get[id] :: getGood
if ($_API === "getGood") {
    $_ID = (int) $_GET['id'];
    $good = $sql->fetch("SELECT `id`, `name`, `msg`, `keywords`, `screens`, `file`, `copies`, `wmr`, `id_user`, `time` FROM `shop_goods` WHERE `id` = '$_ID' LIMIT 1");
    $good['screens'] = unserialize($good['screens']);
    $good['hash'] = md5($good['file']);
    foreach ($good['screens'] as $_key => $_value) {
        $good['screens'][$_key] = "http://4i4i.ru/_images/screen/shop/{$_value}.png";
    } unset($_key, $_value);
    $good['user'] = getUser($good['id_user']);
    unset($good['id_user'], $good['user']['wmr'], $good['file']);
    exit(Json_encode($good));
}

// json :: get :: getBalance
if ($_API === "getBalance") {
    $user = getUser(1201);
    exit(json_encode($user['wmr']));
}
// json :: get :: balance

