예제 #1
0
function user_session_get_secret($userId)
{
    lets_use('core_config', 'storage_nosql');
    $secret = storage_nosql_get_prefix(CORE_CONFIG_REDIS_MAIN, USER_SESSION_REDIS_KEY_PREFIX, $userId);
    if ($secret === USER_SESSION_REDIS_MISSING_RECORD) {
        core_log('cache stored missing secret for user:'******'storage_db');
        $secret = storage_db_get_value(USER_SESSION_DB_TABLE, 'secret', [['user_id', $userId]]);
        core_log('secret found in db: ' . $secret);
        storage_nosql_set_prefix(CORE_CONFIG_REDIS_MAIN, USER_SESSION_REDIS_KEY_PREFIX, $userId, $secret ? $secret : USER_SESSION_REDIS_MISSING_RECORD);
    }
    return $secret;
}
예제 #2
0
function billing_account_get_account($ownerId, $type, $autoCreate)
{
    lets_use('storage_db');
    $accountId = storage_db_get_value(BILLING_ACCOUNT_DB_TABLE, BILLING_ACCOUNT_FIELD_ID, [[BILLING_ACCOUNT_FIELD_OWNER_ID, $ownerId], [BILLING_ACCOUNT_FIELD_TYPE, $type]], ['LIMIT' => 1]);
    if (storage_db_get_last_error(BILLING_ACCOUNT_DB_TABLE)) {
        core_error('cant fetch account ' . json_encode(func_get_args()));
        return false;
    }
    // create account
    if (!$accountId && $autoCreate) {
        $bind = [BILLING_ACCOUNT_FIELD_OWNER_ID => $ownerId, BILLING_ACCOUNT_FIELD_TYPE => $type, BILLING_ACCOUNT_FIELD_CREATED => time()];
        $accountId = storage_db_insert_row(BILLING_ACCOUNT_DB_TABLE, $bind);
        if (!$accountId) {
            core_error('cant create an account ' . json_encode(func_get_args()));
            return false;
        }
    }
    return $accountId;
}
예제 #3
0
function billing_balance_get_account_amount($accountId)
{
    lets_use('storage_db');
    $amount = storage_db_get_value(BILLING_BALANCE_DB_TABLE, BILLING_BALANCE_FIELD_AMOUNT, [[BILLING_BALANCE_FIELD_ACCOUNT_ID, $accountId]]);
    return $amount ? _billing_balance_unpack_money($amount) : 0;
}
예제 #4
0
function user_register_get_user_id_by_email($email)
{
    lets_use('storage_db');
    $authUserId = storage_db_get_value('users', 'id', [['email', $email]]);
    return $authUserId;
}