Example #1
0
function core_dump($data, $data2 = null)
{
    ob_start();
    foreach (func_get_args() as $val) {
        var_dump($val);
    }
    core_log(ob_get_clean());
}
Example #2
0
/**
 * @param mysqli $connection
 * @param string $table
 *
 * @param string $query
 *
 * @return bool
 */
function _storage_db_check($connection, $table, $query = '')
{
    core_log($query, __FUNCTION__);
    if ($connection->error) {
        trigger_error($connection->error . ' in table: ' . $table . ' on query: ' . $query);
        return true;
    }
    return false;
}
Example #3
0
function user_self_balance()
{
    lets_use('billing_balance', 'billing_account');
    $userId = user_self_id();
    core_log('user_id: ' . $userId, __FUNCTION__);
    if (!$userId) {
        return 0;
    }
    $account = billing_account_get_user_main_account($userId);
    return billing_balance_get_account_amount($account);
}
Example #4
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;
}
Example #5
0
function web_controller_auth_auth()
{
    $email = web_router_get_param('email');
    $pass = web_router_get_param('pass');
    if (web_router_get_method() === 'POST') {
        lets_use('user_register');
        $userId = user_register_get_user_id_by_email($email);
        if ($userId) {
            lets_use('user_session');
            core_log('user found: ' . $userId);
            $realSecret = user_session_get_secret($userId);
            $checkSecret = user_session_build_secret($pass);
            if ($realSecret === $checkSecret) {
                $token = user_session_build_token($userId, $checkSecret);
                user_session_write_session_cookie($userId, $token, 86400 * 30);
                web_response_redirect('/');
                return;
            }
        }
        web_router_render_page('auth', 'auth', ['msg' => 'Для данного адреса почты и пароля не найдено ни одного пользователя.']);
        return;
    }
    web_router_render_page('auth', 'auth');
}
Example #6
0
 function core_log_warning($message)
 {
     core_log('WARNING', $message);
 }
Example #7
0
function storage_nosql_set_prefix($redisId, $prefix, $key, $value)
{
    $connect = _storage_nosql_connect($redisId);
    if (!$connect) {
        core_error('Missing connection to redis on ' . __FUNCTION__);
        return null;
    }
    if ($value === null) {
        core_log('REDIS DEL PREFIX: ' . $prefix . '::' . $key, __FUNCTION__);
        return $connect->hDel($prefix, $key);
    }
    core_log('REDIS SET PREFIX: ' . $prefix . '::' . $key . ' = ' . $value, __FUNCTION__);
    return $connect->hSet($prefix, $key, $value);
}