Connector Open-Source Code

Browse connector files locally. Exchange API keys stay on your device.

ui/finish.php

<?php
// /opt/nuxvision_connector/ui/finish.php
declare(strict_types=1);

require_once __DIR__ . '/common.php';

/* -------------------- local helpers (same as others) -------------------- */
function current_instance_id(): int {
    $id = 0;
    if (isset($_GET['instance_id']))  $id = to_int($_GET['instance_id'], 0);
    if (isset($_POST['instance_id'])) $id = to_int($_POST['instance_id'], $id);
    if ($id <= 0) $id = nv_instance_id_from_session();
    return $id > 0 ? $id : 0;
}

function cfg_defaults(): array {
    return [
        'nuxvision' => [
            'base_url' => '',
            'api_key'  => '',
            'timeout'  => 8,
        ],
        'exchange' => [
            'name'       => '',
            'api_key'    => '',
            'api_secret' => '',
        ],
    ];
}

function load_config(int $instanceId): array {
    $d = cfg_defaults();
    if ($instanceId <= 0) return $d;

    $path = nv_instance_config_path($instanceId);
    if (!is_file($path)) return $d;

    $cfg = @require $path;
    if (!is_array($cfg)) return $d;

    foreach (['nuxvision','exchange','loop'] as $k) {
        if (isset($cfg[$k]) && is_array($cfg[$k])) {
            $d[$k] = array_replace($d[$k], $cfg[$k]);
        }
    }
    return $d;
}

/* -------------------- page logic -------------------- */
$instanceId = current_instance_id();
if ($instanceId <= 0) {
    nv_flash_set('err', 'Missing instance_id. Please start from Step 1.');
    header('Location: ./nuxvision.php');
    exit;
}
nv_set_instance_in_session($instanceId);

$cfg = load_config($instanceId);

// basic validation
$nvBase = trim((string)($cfg['nuxvision']['base_url'] ?? ''));
$nvKey  = trim((string)($cfg['nuxvision']['api_key'] ?? ''));
$exName = trim((string)($cfg['exchange']['name'] ?? ''));

render_header('Finish', 'Step 3 — Finish');
render_flash();

$cfgPath = nv_instance_config_path($instanceId);
?>
<div class="nv-card">
    <div class="nv-titlebar">
        <strong>Done</strong>
        <div class="d-flex align-items-center gap-2">
            <span class="nv-muted">Instance <?=h((string)$instanceId)?></span>
            <a class="btn btn-soft btn-sm" href="./index.php" title="Home">
                <i class="bi bi-house me-1"></i>Home
            </a>
        </div>
    </div>
    <div class="nv-pad">
        <div class="row g-3">
            <div class="col-12">
                <div class="nv-muted2">
                    Trading settings are configured on NuxVision. The connector only needs this instance config file and will fetch settings from the API at runtime.
                </div>
            </div>

            <div class="col-12">
                <div class="nv-muted small mb-2">Config file path</div>
                <div class="mono"><?=h($cfgPath)?></div>
            </div>

            <div class="col-12">
                <hr class="nv-soft">
                <div class="nv-muted small">Next</div>
                <div class="mt-2">
                    <div class="mono">php runner.php --instance_id=<?=h((string)$instanceId)?></div>
                </div>
            </div>
        </div>

        <div class="d-flex flex-wrap gap-2 justify-content-between mt-4">
            <a class="btn btn-soft" href="./exchange.php?instance_id=<?=h((string)$instanceId)?>">
                <i class="bi bi-arrow-left me-1"></i>Back
            </a>
            <a class="btn btn-accent" href="./index.php">
                <i class="bi bi-hdd-stack me-1"></i>Go to Instances
            </a>
        </div>
    </div>
</div>
<?php render_footer(); ?>