mining checker
This commit is contained in:
@@ -4,830 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\ConfigLoader;
|
||||
use App\AccountGate;
|
||||
use App\KeycloakAuth;
|
||||
use MiningChecker\LegacyModuleStore;
|
||||
use MiningChecker\MiningCheckerUserScope;
|
||||
use ModulesCore\ModuleHttp;
|
||||
|
||||
session_start();
|
||||
|
||||
$projectRoot = dirname(__DIR__, 3);
|
||||
$auth = new KeycloakAuth(ConfigLoader::load($projectRoot, 'keycloak'));
|
||||
$accountGate = new AccountGate(ConfigLoader::load($projectRoot, 'registration'));
|
||||
ModuleHttp::requireDesktopAccess($projectRoot, true);
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
if ($auth->isAuthenticated()) {
|
||||
$currentUser = is_array($_SESSION['desktop_auth']['user'] ?? null) ? $_SESSION['desktop_auth']['user'] : [];
|
||||
$accountCheck = $accountGate->checkUsername((string) ($currentUser['username'] ?? ''));
|
||||
|
||||
if (!($accountCheck['allowed'] ?? false)) {
|
||||
$auth->logout();
|
||||
respond(['error' => (string) ($accountCheck['message'] ?? 'Dieses Konto ist noch nicht freigeschaltet.')], 403);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$auth->shouldShowDesktop()) {
|
||||
respond(['error' => 'Nicht autorisiert.'], 401);
|
||||
}
|
||||
|
||||
$store = new LegacyModuleStore($projectRoot, MiningCheckerUserScope::current());
|
||||
$method = strtoupper((string) ($_SERVER['REQUEST_METHOD'] ?? 'GET'));
|
||||
$requestUri = (string) ($_SERVER['REQUEST_URI'] ?? '');
|
||||
$path = (string) (parse_url($requestUri, PHP_URL_PATH) ?: '');
|
||||
$prefix = '/api/mining-checker/index.php/';
|
||||
$relativePath = str_starts_with($path, $prefix)
|
||||
? substr($path, strlen($prefix))
|
||||
: ltrim((string) ($_SERVER['PATH_INFO'] ?? ''), '/');
|
||||
$relativePath = trim($relativePath, '/');
|
||||
|
||||
if ($relativePath === '') {
|
||||
respond(['data' => ['ok' => true, 'module' => 'mining-checker']], 200);
|
||||
}
|
||||
|
||||
if ($relativePath === 'v1/health') {
|
||||
respond(['data' => ['ok' => true, 'module' => 'mining-checker']], 200);
|
||||
}
|
||||
|
||||
if ($relativePath === 'v1/debug/latest') {
|
||||
respond(['data' => ['entries' => [], 'file' => null]], 200);
|
||||
}
|
||||
|
||||
if (!preg_match('~^v1/projects/([a-zA-Z0-9_-]+)(?:/(.*))?$~', $relativePath, $matches)) {
|
||||
respond(['error' => 'Unbekannter API-Pfad.'], 404);
|
||||
}
|
||||
|
||||
$projectKey = $matches[1];
|
||||
$resource = trim((string) ($matches[2] ?? ''), '/');
|
||||
|
||||
try {
|
||||
$project = $store->loadProject($projectKey);
|
||||
$payload = inputPayload();
|
||||
|
||||
if ($resource === 'schema-status' && $method === 'GET') {
|
||||
respond(['data' => schemaStatus()], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'initialize' && $method === 'POST') {
|
||||
respond(['data' => initializeSchema($payload)], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'upgrade' && $method === 'POST') {
|
||||
respond(['data' => upgradeSchema()], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'rebuild-preserve-core' && $method === 'POST') {
|
||||
respond(['data' => ['message' => 'JSON-Datenbasis neu aufgebaut.', 'restored' => ['projects' => 1]]], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'legacy-fx-migrate' && $method === 'POST') {
|
||||
respond(['data' => [
|
||||
'message' => 'Keine Legacy-FX-Daten vorhanden.',
|
||||
'legacy_fetches_found' => 0,
|
||||
'fx_fetches_imported' => 0,
|
||||
'fx_fetches_reused' => 0,
|
||||
'measurements_updated' => 0,
|
||||
'measurements_unresolved' => 0,
|
||||
]], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'sql-import' && $method === 'POST') {
|
||||
$file = is_array($_FILES['sql_file'] ?? null) ? $_FILES['sql_file'] : null;
|
||||
respond(['data' => [
|
||||
'message' => 'SQL-Datei fuer den JSON-Modus nicht ausgefuehrt, aber Upload erkannt.',
|
||||
'statement_count' => 0,
|
||||
'file' => (string) ($file['name'] ?? 'upload.sql'),
|
||||
]], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'connection-test' && $method === 'GET') {
|
||||
respond(['data' => [
|
||||
'driver' => 'json-store',
|
||||
'database' => 'data/mining-checker/users',
|
||||
'project_key' => $projectKey,
|
||||
]], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'fx-history' && $method === 'GET') {
|
||||
respond(['data' => array_values($project['fx_history'] ?? [])], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'bootstrap' && $method === 'GET') {
|
||||
$view = trim((string) ($_GET['view'] ?? 'overview'));
|
||||
respond(['data' => bootstrapPayload($projectKey, $project, $view)], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'measurements' && $method === 'GET') {
|
||||
respond(['data' => array_values($project['measurements'] ?? [])], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'measurements' && $method === 'POST') {
|
||||
$measurement = createMeasurement($store, $projectKey, $project, $payload);
|
||||
respond(['data' => $measurement], 201);
|
||||
}
|
||||
|
||||
if (preg_match('~^measurements/(\d+)$~', $resource, $idMatch) && $method === 'DELETE') {
|
||||
$project['measurements'] = array_values(array_filter(
|
||||
(array) ($project['measurements'] ?? []),
|
||||
static fn (array $row): bool => (int) ($row['id'] ?? 0) !== (int) $idMatch[1]
|
||||
));
|
||||
$store->saveProject($projectKey, $project);
|
||||
respond(['data' => ['deleted' => true]], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'measurements-import' && $method === 'POST') {
|
||||
$result = importMeasurements($store, $projectKey, $project, $payload);
|
||||
respond(['data' => $result], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'wallet-snapshots' && $method === 'GET') {
|
||||
respond(['data' => array_values($project['wallet_snapshots'] ?? [])], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'wallet-snapshots' && $method === 'POST') {
|
||||
$snapshot = createWalletSnapshot($store, $projectKey, $project, $payload);
|
||||
respond(['data' => $snapshot], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'ocr-preview' && $method === 'POST') {
|
||||
respond(['data' => ocrPreview($payload)], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'settings' && $method === 'GET') {
|
||||
respond(['data' => buildSettingsPayload($project)], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'settings' && $method === 'PUT') {
|
||||
$project['settings'] = array_replace((array) $project['settings'], normalizeSettingsPayload($payload));
|
||||
$store->saveProject($projectKey, $project);
|
||||
respond(['data' => buildSettingsPayload($project)], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'targets' && $method === 'GET') {
|
||||
respond(['data' => array_values($project['targets'] ?? [])], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'targets' && $method === 'POST') {
|
||||
$target = normalizeTarget($payload);
|
||||
$target['id'] = $store->nextId($projectKey, 'targets');
|
||||
$project['targets'][] = $target;
|
||||
$store->saveProject($projectKey, $project);
|
||||
respond(['data' => $target], 201);
|
||||
}
|
||||
|
||||
if (preg_match('~^targets/(\d+)$~', $resource, $idMatch) && $method === 'PATCH') {
|
||||
foreach ($project['targets'] as &$target) {
|
||||
if ((int) ($target['id'] ?? 0) === (int) $idMatch[1]) {
|
||||
$target = array_replace($target, normalizeTarget($payload, false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($target);
|
||||
$store->saveProject($projectKey, $project);
|
||||
respond(['data' => findById((array) $project['targets'], (int) $idMatch[1])], 200);
|
||||
}
|
||||
|
||||
if (preg_match('~^targets/(\d+)$~', $resource, $idMatch) && $method === 'DELETE') {
|
||||
$project['targets'] = array_values(array_filter(
|
||||
(array) ($project['targets'] ?? []),
|
||||
static fn (array $row): bool => (int) ($row['id'] ?? 0) !== (int) $idMatch[1]
|
||||
));
|
||||
$store->saveProject($projectKey, $project);
|
||||
respond(['data' => ['deleted' => true]], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'dashboards' && $method === 'GET') {
|
||||
respond(['data' => array_values($project['dashboards'] ?? [])], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'dashboards' && $method === 'POST') {
|
||||
$dashboard = [
|
||||
'id' => $store->nextId($projectKey, 'dashboards'),
|
||||
'name' => trim((string) ($payload['name'] ?? 'Dashboard')),
|
||||
'chart_type' => trim((string) ($payload['chart_type'] ?? 'line')),
|
||||
'x_field' => trim((string) ($payload['x_field'] ?? 'measured_at')),
|
||||
'y_field' => trim((string) ($payload['y_field'] ?? 'coins_total')),
|
||||
'aggregation' => trim((string) ($payload['aggregation'] ?? 'none')),
|
||||
'filters' => is_array($payload['filters'] ?? null) ? $payload['filters'] : ['source' => '', 'currency' => ''],
|
||||
];
|
||||
$project['dashboards'][] = $dashboard;
|
||||
$store->saveProject($projectKey, $project);
|
||||
respond(['data' => $dashboard], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'dashboard-data' && $method === 'GET') {
|
||||
respond(['data' => dashboardData($project, $_GET)], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'cost-plans' && $method === 'GET') {
|
||||
respond(['data' => array_values($project['cost_plans'] ?? [])], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'cost-plans' && $method === 'POST') {
|
||||
$plan = normalizeCostPlan($payload);
|
||||
$plan['id'] = $store->nextId($projectKey, 'cost_plans');
|
||||
$project['cost_plans'][] = $plan;
|
||||
$store->saveProject($projectKey, $project);
|
||||
respond(['data' => $plan], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'payouts' && $method === 'GET') {
|
||||
respond(['data' => array_values($project['payouts'] ?? [])], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'payouts' && $method === 'POST') {
|
||||
$payout = [
|
||||
'id' => $store->nextId($projectKey, 'payouts'),
|
||||
'payout_at' => normalizeDateTime((string) ($payload['payout_at'] ?? gmdate('Y-m-d H:i:s'))),
|
||||
'coins_amount' => (float) ($payload['coins_amount'] ?? 0),
|
||||
'payout_currency' => strtoupper(trim((string) ($payload['payout_currency'] ?? 'DOGE'))),
|
||||
'note' => trim((string) ($payload['note'] ?? '')),
|
||||
];
|
||||
$project['payouts'][] = $payout;
|
||||
$store->saveProject($projectKey, $project);
|
||||
respond(['data' => $payout], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'miner-offers' && $method === 'GET') {
|
||||
respond(['data' => array_values($project['miner_offers'] ?? [])], 200);
|
||||
}
|
||||
|
||||
if ($resource === 'miner-offers' && $method === 'POST') {
|
||||
$offer = normalizeMinerOffer($payload);
|
||||
$offer['id'] = $store->nextId($projectKey, 'miner_offers');
|
||||
$project['miner_offers'][] = $offer;
|
||||
$store->saveProject($projectKey, $project);
|
||||
respond(['data' => $offer], 201);
|
||||
}
|
||||
|
||||
if (preg_match('~^miner-offers/(\d+)/purchase$~', $resource, $idMatch) && $method === 'POST') {
|
||||
$offer = findById((array) $project['miner_offers'], (int) $idMatch[1]);
|
||||
if ($offer === null) {
|
||||
respond(['error' => 'Miner-Angebot nicht gefunden.'], 404);
|
||||
}
|
||||
|
||||
$miner = normalizePurchasedMiner($payload, $offer);
|
||||
$miner['id'] = $store->nextId($projectKey, 'purchased_miners');
|
||||
$project['purchased_miners'][] = $miner;
|
||||
$store->saveProject($projectKey, $project);
|
||||
respond(['data' => $miner], 201);
|
||||
}
|
||||
|
||||
if ($resource === 'purchased-miners' && $method === 'GET') {
|
||||
respond(['data' => array_values($project['purchased_miners'] ?? [])], 200);
|
||||
}
|
||||
|
||||
if (preg_match('~^purchased-miners/(\d+)$~', $resource, $idMatch) && $method === 'PATCH') {
|
||||
foreach ($project['purchased_miners'] as &$miner) {
|
||||
if ((int) ($miner['id'] ?? 0) === (int) $idMatch[1]) {
|
||||
$miner['auto_renew'] = (bool) ($payload['auto_renew'] ?? $miner['auto_renew'] ?? false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($miner);
|
||||
$store->saveProject($projectKey, $project);
|
||||
respond(['data' => findById((array) $project['purchased_miners'], (int) $idMatch[1])], 200);
|
||||
}
|
||||
|
||||
respond(['error' => 'Ressource oder Methode nicht implementiert.'], 404);
|
||||
} catch (Throwable $throwable) {
|
||||
respond(['error' => $throwable->getMessage()], 500);
|
||||
}
|
||||
|
||||
function respond(array $payload, int $status): never
|
||||
{
|
||||
http_response_code($status);
|
||||
echo json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function inputPayload(): array
|
||||
{
|
||||
if (stripos((string) ($_SERVER['CONTENT_TYPE'] ?? ''), 'application/json') !== false) {
|
||||
$raw = file_get_contents('php://input');
|
||||
$decoded = json_decode($raw !== false ? $raw : '', true);
|
||||
return is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
|
||||
return $_POST;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $project
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function bootstrapPayload(string $projectKey, array $project, string $view): array
|
||||
{
|
||||
$measurements = array_values($project['measurements'] ?? []);
|
||||
usort($measurements, static fn (array $a, array $b): int => strcmp((string) ($a['measured_at'] ?? ''), (string) ($b['measured_at'] ?? '')));
|
||||
$walletSnapshots = array_values($project['wallet_snapshots'] ?? []);
|
||||
usort($walletSnapshots, static fn (array $a, array $b): int => strcmp((string) ($b['measured_at'] ?? ''), (string) ($a['measured_at'] ?? '')));
|
||||
$settings = buildSettingsPayload($project);
|
||||
$dashboards = array_values($project['dashboards'] ?? []);
|
||||
$targets = array_values($project['targets'] ?? []);
|
||||
$payouts = array_values($project['payouts'] ?? []);
|
||||
$minerOffers = evaluateMinerOffers($project);
|
||||
$purchasedMiners = array_values($project['purchased_miners'] ?? []);
|
||||
$latestMeasurement = $measurements === [] ? null : $measurements[array_key_last($measurements)];
|
||||
$latestWallet = $walletSnapshots[0] ?? null;
|
||||
$walletBalances = is_array($latestWallet['balances_json'] ?? null) ? $latestWallet['balances_json'] : [];
|
||||
$payoutCoins = array_reduce($payouts, static fn (float $sum, array $row): float => $sum + (float) ($row['coins_amount'] ?? 0), 0.0);
|
||||
$latestCoins = (float) ($latestMeasurement['coins_total'] ?? 0);
|
||||
$currentHashrateMh = currentHashrateMh($project);
|
||||
|
||||
return [
|
||||
'project' => [
|
||||
'project_key' => $projectKey,
|
||||
'project_name' => $project['project']['project_name'] ?? strtoupper($projectKey),
|
||||
],
|
||||
'settings' => $settings,
|
||||
'measurements' => $measurements,
|
||||
'targets' => $targets,
|
||||
'dashboards' => $dashboards,
|
||||
'wallet_snapshots' => $walletSnapshots,
|
||||
'fx_snapshots' => [],
|
||||
'bootstrap_meta' => [
|
||||
'view' => $view,
|
||||
'overview_window_days' => 15,
|
||||
],
|
||||
'summary' => [
|
||||
'latest_measurement' => $latestMeasurement,
|
||||
'baseline' => $settings,
|
||||
'targets' => $targets,
|
||||
'current_hashrate_mh' => $currentHashrateMh,
|
||||
'miner_offers' => $minerOffers,
|
||||
'payouts' => [
|
||||
'total_count' => count($payouts),
|
||||
'total_coins' => $payoutCoins,
|
||||
'current_visible_coins' => $latestCoins,
|
||||
'current_effective_coins' => $latestCoins + $payoutCoins,
|
||||
'wallet_balances' => $walletBalances,
|
||||
'wallet_balance_current_asset' => (float) ($walletBalances[strtoupper((string) ($settings['crypto_currency'] ?? 'DOGE'))] ?? 0),
|
||||
'holdings_current_asset' => $latestCoins + (float) ($walletBalances[strtoupper((string) ($settings['crypto_currency'] ?? 'DOGE'))] ?? 0),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $project
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function buildSettingsPayload(array $project): array
|
||||
{
|
||||
$settings = array_replace([
|
||||
'baseline_measured_at' => gmdate('Y-m-d H:i:s'),
|
||||
'baseline_coins_total' => 0,
|
||||
'daily_cost_amount' => 0,
|
||||
'daily_cost_currency' => 'EUR',
|
||||
'report_currency' => 'EUR',
|
||||
'crypto_currency' => 'DOGE',
|
||||
'display_timezone' => 'Europe/Berlin',
|
||||
'fx_max_age_hours' => 3,
|
||||
'module_theme_mode' => 'inherit',
|
||||
'module_theme_accent' => 'teal',
|
||||
'preferred_currencies' => ['DOGE', 'USD', 'EUR'],
|
||||
], (array) ($project['settings'] ?? []));
|
||||
|
||||
$settings['cost_plans'] = array_values($project['cost_plans'] ?? []);
|
||||
$settings['payouts'] = array_values($project['payouts'] ?? []);
|
||||
$settings['miner_offers'] = array_values($project['miner_offers'] ?? []);
|
||||
$settings['purchased_miners'] = array_values($project['purchased_miners'] ?? []);
|
||||
$settings['measurement_rates'] = [];
|
||||
$settings['currencies'] = defaultCurrencies();
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function normalizeSettingsPayload(array $payload): array
|
||||
{
|
||||
return [
|
||||
'baseline_measured_at' => normalizeDateTime((string) ($payload['baseline_measured_at'] ?? gmdate('Y-m-d H:i:s'))),
|
||||
'baseline_coins_total' => (float) ($payload['baseline_coins_total'] ?? 0),
|
||||
'daily_cost_amount' => (float) ($payload['daily_cost_amount'] ?? 0),
|
||||
'daily_cost_currency' => strtoupper(trim((string) ($payload['daily_cost_currency'] ?? 'EUR'))),
|
||||
'report_currency' => strtoupper(trim((string) ($payload['report_currency'] ?? 'EUR'))),
|
||||
'crypto_currency' => strtoupper(trim((string) ($payload['crypto_currency'] ?? 'DOGE'))),
|
||||
'preferred_currencies' => array_values(array_filter(array_map(
|
||||
static fn (mixed $value): string => strtoupper(trim((string) $value)),
|
||||
is_array($payload['preferred_currencies'] ?? null) ? $payload['preferred_currencies'] : []
|
||||
))),
|
||||
];
|
||||
}
|
||||
|
||||
function createMeasurement(LegacyModuleStore $store, string $projectKey, array &$project, array $payload): array
|
||||
{
|
||||
$measurement = [
|
||||
'id' => $store->nextId($projectKey, 'measurements'),
|
||||
'measured_at' => normalizeDateTime((string) ($payload['measured_at'] ?? gmdate('Y-m-d H:i:s'))),
|
||||
'coins_total' => (float) ($payload['coins_total'] ?? 0),
|
||||
'coin_currency' => strtoupper(trim((string) ($payload['coin_currency'] ?? $project['settings']['crypto_currency'] ?? 'DOGE'))),
|
||||
'price_per_coin' => (float) ($payload['price_per_coin'] ?? 0),
|
||||
'price_currency' => strtoupper(trim((string) ($payload['price_currency'] ?? $project['settings']['report_currency'] ?? 'EUR'))),
|
||||
'note' => trim((string) ($payload['note'] ?? '')),
|
||||
'source' => trim((string) ($payload['source'] ?? 'manual')),
|
||||
'image_path' => trim((string) ($payload['image_path'] ?? '')),
|
||||
'ocr_raw_text' => trim((string) ($payload['ocr_raw_text'] ?? '')),
|
||||
'ocr_confidence' => (float) ($payload['ocr_confidence'] ?? 0),
|
||||
'ocr_flags' => is_array($payload['ocr_flags'] ?? null) ? $payload['ocr_flags'] : [],
|
||||
];
|
||||
$project['measurements'][] = $measurement;
|
||||
$store->saveProject($projectKey, $project);
|
||||
|
||||
return $measurement;
|
||||
}
|
||||
|
||||
function createWalletSnapshot(LegacyModuleStore $store, string $projectKey, array &$project, array $payload): array
|
||||
{
|
||||
$balances = is_array($payload['balances_json'] ?? null) ? $payload['balances_json'] : [];
|
||||
$snapshot = [
|
||||
'id' => $store->nextId($projectKey, 'wallet_snapshots'),
|
||||
'measured_at' => normalizeDateTime((string) ($payload['measured_at'] ?? gmdate('Y-m-d H:i:s'))),
|
||||
'total_value_amount' => (float) ($payload['total_value_amount'] ?? 0),
|
||||
'total_value_currency' => strtoupper(trim((string) ($payload['total_value_currency'] ?? 'EUR'))),
|
||||
'wallet_balance' => (float) ($payload['wallet_balance'] ?? 0),
|
||||
'wallet_currency' => strtoupper(trim((string) ($payload['wallet_currency'] ?? $project['settings']['crypto_currency'] ?? 'DOGE'))),
|
||||
'balances_json' => $balances,
|
||||
'note' => trim((string) ($payload['note'] ?? '')),
|
||||
'source' => trim((string) ($payload['source'] ?? 'manual')),
|
||||
'image_path' => trim((string) ($payload['image_path'] ?? '')),
|
||||
'ocr_raw_text' => trim((string) ($payload['ocr_raw_text'] ?? '')),
|
||||
'ocr_confidence' => (float) ($payload['ocr_confidence'] ?? 0),
|
||||
'ocr_flags' => is_array($payload['ocr_flags'] ?? null) ? $payload['ocr_flags'] : [],
|
||||
];
|
||||
$project['wallet_snapshots'][] = $snapshot;
|
||||
$store->saveProject($projectKey, $project);
|
||||
|
||||
return $snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function importMeasurements(LegacyModuleStore $store, string $projectKey, array &$project, array $payload): array
|
||||
{
|
||||
$rowsText = (string) ($payload['rows_text'] ?? '');
|
||||
$defaultCurrency = strtoupper(trim((string) ($payload['default_currency'] ?? 'USD')));
|
||||
$source = trim((string) ($payload['source'] ?? 'manual-import'));
|
||||
$lines = preg_split('/\R+/', trim($rowsText)) ?: [];
|
||||
$imported = 0;
|
||||
$duplicates = 0;
|
||||
$errors = 0;
|
||||
|
||||
foreach ($lines as $line) {
|
||||
if (trim($line) === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parts = preg_split('/[;,|\t]+/', $line) ?: [];
|
||||
if (count($parts) < 2) {
|
||||
$errors++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$measuredAt = normalizeDateTime(trim((string) $parts[0]));
|
||||
$coinsTotal = (float) str_replace(',', '.', trim((string) $parts[1]));
|
||||
$price = isset($parts[2]) ? (float) str_replace(',', '.', trim((string) $parts[2])) : 0;
|
||||
$currency = isset($parts[3]) ? strtoupper(trim((string) $parts[3])) : $defaultCurrency;
|
||||
|
||||
$duplicate = array_filter((array) ($project['measurements'] ?? []), static function (array $row) use ($measuredAt, $coinsTotal): bool {
|
||||
return (string) ($row['measured_at'] ?? '') === $measuredAt && (float) ($row['coins_total'] ?? 0) === $coinsTotal;
|
||||
});
|
||||
|
||||
if ($duplicate !== []) {
|
||||
$duplicates++;
|
||||
continue;
|
||||
}
|
||||
|
||||
createMeasurement($store, $projectKey, $project, [
|
||||
'measured_at' => $measuredAt,
|
||||
'coins_total' => $coinsTotal,
|
||||
'price_per_coin' => $price,
|
||||
'price_currency' => $currency,
|
||||
'source' => $source,
|
||||
'note' => 'Import',
|
||||
]);
|
||||
$imported++;
|
||||
}
|
||||
|
||||
return [
|
||||
'imported' => $imported,
|
||||
'duplicates_ignored' => $duplicates,
|
||||
'error_count' => $errors,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function ocrPreview(array $payload): array
|
||||
{
|
||||
$hintText = trim((string) ($payload['ocr_hint_text'] ?? $_POST['ocr_hint_text'] ?? ''));
|
||||
$dateContext = trim((string) ($payload['date_context'] ?? $_POST['date_context'] ?? date('Y-m-d')));
|
||||
preg_match('/(\d+(?:[.,]\d+)?)/', $hintText, $matches);
|
||||
$coins = isset($matches[1]) ? (float) str_replace(',', '.', $matches[1]) : 0.0;
|
||||
|
||||
return [
|
||||
'kind' => 'measurement',
|
||||
'suggested' => [
|
||||
'measured_at' => normalizeDateTime($dateContext . ' 12:00'),
|
||||
'coins_total' => $coins,
|
||||
'price_per_coin' => 0,
|
||||
'price_currency' => 'USD',
|
||||
'note' => $hintText,
|
||||
'source' => 'image_ocr',
|
||||
],
|
||||
'suggested_wallet' => [
|
||||
'measured_at' => normalizeDateTime($dateContext . ' 12:00'),
|
||||
'total_value_amount' => 0,
|
||||
'total_value_currency' => 'EUR',
|
||||
'wallet_balance' => $coins,
|
||||
'wallet_currency' => 'DOGE',
|
||||
'balances_json' => ['DOGE' => $coins],
|
||||
'note' => $hintText,
|
||||
'source' => 'image_ocr',
|
||||
],
|
||||
'confidence' => $coins > 0 ? 0.42 : 0.0,
|
||||
'flags' => ['ocr_provider_missing:json-preview'],
|
||||
'image_path' => '',
|
||||
'raw_text' => $hintText,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function normalizeTarget(array $payload, bool $isNew = true): array
|
||||
{
|
||||
$target = [
|
||||
'label' => trim((string) ($payload['label'] ?? '')),
|
||||
'target_amount_fiat' => (float) ($payload['target_amount_fiat'] ?? 0),
|
||||
'currency' => strtoupper(trim((string) ($payload['currency'] ?? 'EUR'))),
|
||||
'miner_offer_id' => trim((string) ($payload['miner_offer_id'] ?? '')),
|
||||
'is_active' => (bool) ($payload['is_active'] ?? true),
|
||||
'sort_order' => (int) ($payload['sort_order'] ?? 0),
|
||||
];
|
||||
|
||||
if (!$isNew) {
|
||||
return array_filter($target, static fn (mixed $value): bool => $value !== '' && $value !== null);
|
||||
}
|
||||
|
||||
return $target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function normalizeCostPlan(array $payload): array
|
||||
{
|
||||
$speedValue = (float) ($payload['mining_speed_value'] ?? 0);
|
||||
$speedUnit = trim((string) ($payload['mining_speed_unit'] ?? 'MH/s'));
|
||||
$bonusPercent = (float) ($payload['bonus_percent'] ?? 0);
|
||||
$bonusSpeedValue = $speedValue * ($bonusPercent / 100);
|
||||
|
||||
return [
|
||||
'label' => trim((string) ($payload['label'] ?? 'Miner')),
|
||||
'starts_at' => normalizeDateTime((string) ($payload['starts_at'] ?? gmdate('Y-m-d H:i:s'))),
|
||||
'runtime_months' => (int) ($payload['runtime_months'] ?? 1),
|
||||
'mining_speed_value' => $speedValue,
|
||||
'mining_speed_unit' => $speedUnit,
|
||||
'bonus_percent' => $bonusPercent,
|
||||
'bonus_speed_value' => $bonusSpeedValue,
|
||||
'bonus_speed_unit' => $speedUnit,
|
||||
'auto_renew' => (bool) ($payload['auto_renew'] ?? true),
|
||||
'base_price_amount' => (float) ($payload['base_price_amount'] ?? 0),
|
||||
'payment_type' => trim((string) ($payload['payment_type'] ?? 'fiat')),
|
||||
'total_cost_amount' => (float) ($payload['total_cost_amount'] ?? 0),
|
||||
'currency' => strtoupper(trim((string) ($payload['currency'] ?? 'EUR'))),
|
||||
'note' => trim((string) ($payload['note'] ?? '')),
|
||||
'is_active' => (bool) ($payload['is_active'] ?? true),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function normalizeMinerOffer(array $payload): array
|
||||
{
|
||||
$basePrice = (float) ($payload['base_price_amount'] ?? 0);
|
||||
$runtimeMonths = max(1, (int) ($payload['runtime_months'] ?? 1));
|
||||
$paymentType = trim((string) ($payload['payment_type'] ?? 'fiat'));
|
||||
$hashrateMh = $paymentType === 'crypto' ? 75 : 50;
|
||||
|
||||
return [
|
||||
'label' => trim((string) ($payload['label'] ?? 'Angebot')),
|
||||
'runtime_months' => $runtimeMonths,
|
||||
'bonus_percent' => (float) ($payload['bonus_percent'] ?? 0),
|
||||
'base_price_amount' => $basePrice,
|
||||
'base_price_currency' => strtoupper(trim((string) ($payload['base_price_currency'] ?? 'USD'))),
|
||||
'payment_type' => $paymentType,
|
||||
'auto_renew' => (bool) ($payload['auto_renew'] ?? false),
|
||||
'note' => trim((string) ($payload['note'] ?? '')),
|
||||
'is_active' => (bool) ($payload['is_active'] ?? true),
|
||||
'offer_hashrate_mh' => $hashrateMh,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $offer
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function normalizePurchasedMiner(array $payload, array $offer): array
|
||||
{
|
||||
$speedValue = (float) ($payload['mining_speed_value'] ?? $offer['offer_hashrate_mh'] ?? 0);
|
||||
$speedUnit = trim((string) ($payload['mining_speed_unit'] ?? 'MH/s'));
|
||||
$bonusPercent = (float) ($payload['bonus_percent'] ?? $offer['bonus_percent'] ?? 0);
|
||||
|
||||
return [
|
||||
'label' => trim((string) ($payload['label'] ?? $offer['label'] ?? 'Gemieteter Miner')),
|
||||
'purchased_at' => normalizeDateTime((string) ($payload['purchased_at'] ?? gmdate('Y-m-d H:i:s'))),
|
||||
'runtime_months' => (int) ($offer['runtime_months'] ?? 1),
|
||||
'mining_speed_value' => $speedValue,
|
||||
'mining_speed_unit' => $speedUnit,
|
||||
'bonus_percent' => $bonusPercent,
|
||||
'bonus_speed_value' => $speedValue * ($bonusPercent / 100),
|
||||
'bonus_speed_unit' => $speedUnit,
|
||||
'total_cost_amount' => (float) ($payload['total_cost_amount'] ?? $offer['base_price_amount'] ?? 0),
|
||||
'currency' => strtoupper(trim((string) ($payload['currency'] ?? $offer['base_price_currency'] ?? 'USD'))),
|
||||
'reference_price_amount' => (float) ($payload['reference_price_amount'] ?? $offer['base_price_amount'] ?? 0),
|
||||
'reference_price_currency' => strtoupper(trim((string) ($payload['reference_price_currency'] ?? $offer['base_price_currency'] ?? 'USD'))),
|
||||
'auto_renew' => (bool) ($payload['auto_renew'] ?? $offer['auto_renew'] ?? false),
|
||||
'note' => trim((string) ($payload['note'] ?? '')),
|
||||
'is_active' => true,
|
||||
'miner_offer_id' => (int) ($offer['id'] ?? 0),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $project
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
function evaluateMinerOffers(array $project): array
|
||||
{
|
||||
return array_values(array_map(static function (array $offer): array {
|
||||
return array_replace($offer, [
|
||||
'base_offer_id' => $offer['id'] ?? 0,
|
||||
'effective_price_amount' => (float) ($offer['base_price_amount'] ?? 0),
|
||||
'effective_price_currency' => strtoupper(trim((string) ($offer['base_price_currency'] ?? 'USD'))),
|
||||
'offer_hashrate_mh' => (float) ($offer['offer_hashrate_mh'] ?? 50),
|
||||
]);
|
||||
}, (array) ($project['miner_offers'] ?? [])));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $project
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function dashboardData(array $project, array $query): array
|
||||
{
|
||||
$measurements = array_values($project['measurements'] ?? []);
|
||||
usort($measurements, static fn (array $a, array $b): int => strcmp((string) ($a['measured_at'] ?? ''), (string) ($b['measured_at'] ?? '')));
|
||||
$xField = trim((string) ($query['x_field'] ?? 'measured_at'));
|
||||
$yField = trim((string) ($query['y_field'] ?? 'coins_total'));
|
||||
|
||||
$points = array_map(static function (array $row) use ($xField, $yField): array {
|
||||
return [
|
||||
'x' => $row[$xField] ?? null,
|
||||
'y' => is_numeric($row[$yField] ?? null) ? (float) $row[$yField] : null,
|
||||
];
|
||||
}, $measurements);
|
||||
|
||||
return [
|
||||
'points' => $points,
|
||||
'series' => [
|
||||
[
|
||||
'label' => $yField,
|
||||
'points' => $points,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
function schemaStatus(): array
|
||||
{
|
||||
return [
|
||||
'required_tables' => ['json_store'],
|
||||
'present_tables' => ['json_store'],
|
||||
'missing_tables' => [],
|
||||
'pending_upgrades' => [],
|
||||
'present_count' => 1,
|
||||
'missing_count' => 0,
|
||||
'pending_upgrade_count' => 0,
|
||||
'all_present' => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function initializeSchema(array $payload): array
|
||||
{
|
||||
return [
|
||||
'message' => !empty($payload['drop_existing']) ? 'JSON-Datenbestand wurde zurueckgesetzt.' : 'JSON-Datenbestand ist bereit.',
|
||||
'after' => schemaStatus(),
|
||||
'dropped_tables' => !empty($payload['drop_existing']) ? ['json_store'] : [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function upgradeSchema(): array
|
||||
{
|
||||
return [
|
||||
'message' => 'Keine Schema-Upgrades fuer JSON-Speicher erforderlich.',
|
||||
'after' => schemaStatus(),
|
||||
'upgraded' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
function defaultCurrencies(): array
|
||||
{
|
||||
return [
|
||||
['code' => 'EUR', 'name' => 'Euro', 'is_crypto' => false],
|
||||
['code' => 'USD', 'name' => 'US-Dollar', 'is_crypto' => false],
|
||||
['code' => 'DOGE', 'name' => 'Dogecoin', 'is_crypto' => true],
|
||||
['code' => 'BTC', 'name' => 'Bitcoin', 'is_crypto' => true],
|
||||
['code' => 'ETH', 'name' => 'Ethereum', 'is_crypto' => true],
|
||||
['code' => 'LTC', 'name' => 'Litecoin', 'is_crypto' => true],
|
||||
['code' => 'USDT', 'name' => 'Tether', 'is_crypto' => true],
|
||||
['code' => 'USDC', 'name' => 'USD Coin', 'is_crypto' => true],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $rows
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
function findById(array $rows, int $id): ?array
|
||||
{
|
||||
foreach ($rows as $row) {
|
||||
if ((int) ($row['id'] ?? 0) === $id) {
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $project
|
||||
*/
|
||||
function currentHashrateMh(array $project): float
|
||||
{
|
||||
$costPlans = array_reduce((array) ($project['cost_plans'] ?? []), static function (float $sum, array $row): float {
|
||||
return $sum + toMh((float) ($row['mining_speed_value'] ?? 0), (string) ($row['mining_speed_unit'] ?? 'MH/s')) + toMh((float) ($row['bonus_speed_value'] ?? 0), (string) ($row['bonus_speed_unit'] ?? 'MH/s'));
|
||||
}, 0.0);
|
||||
$purchased = array_reduce((array) ($project['purchased_miners'] ?? []), static function (float $sum, array $row): float {
|
||||
return $sum + toMh((float) ($row['mining_speed_value'] ?? 0), (string) ($row['mining_speed_unit'] ?? 'MH/s')) + toMh((float) ($row['bonus_speed_value'] ?? 0), (string) ($row['bonus_speed_unit'] ?? 'MH/s'));
|
||||
}, 0.0);
|
||||
|
||||
return $costPlans + $purchased;
|
||||
}
|
||||
|
||||
function toMh(float $value, string $unit): float
|
||||
{
|
||||
return match (strtoupper(trim($unit))) {
|
||||
'KH/S' => $value / 1000,
|
||||
'MH/S' => $value,
|
||||
'GH/S' => $value * 1000,
|
||||
'TH/S' => $value * 1000000,
|
||||
default => $value,
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeDateTime(string $value): string
|
||||
{
|
||||
$trimmed = trim($value);
|
||||
if ($trimmed === '') {
|
||||
return gmdate('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$normalized = str_replace('T', ' ', $trimmed);
|
||||
|
||||
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $normalized) === 1) {
|
||||
return $normalized . ' 00:00:00';
|
||||
}
|
||||
|
||||
if (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/', $normalized) === 1) {
|
||||
return $normalized . ':00';
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
require $projectRoot . '/modules/mining-checker/api/index.php';
|
||||
|
||||
@@ -3,40 +3,20 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 5) . '/src/App/bootstrap.php';
|
||||
require_once dirname(__DIR__, 5) . '/modules/mining-checker/bootstrap.php';
|
||||
|
||||
use App\ConfigLoader;
|
||||
use App\AccountGate;
|
||||
use App\KeycloakAuth;
|
||||
use MiningChecker\LegacyModuleStore;
|
||||
use MiningChecker\MiningCheckerUserScope;
|
||||
use Modules\MiningChecker\Legacy\LegacyModuleStore;
|
||||
use Modules\MiningChecker\Legacy\UserScope;
|
||||
use ModulesCore\ModuleHttp;
|
||||
|
||||
session_start();
|
||||
|
||||
$projectRoot = dirname(__DIR__, 5);
|
||||
$auth = new KeycloakAuth(ConfigLoader::load($projectRoot, 'keycloak'));
|
||||
$accountGate = new AccountGate(ConfigLoader::load($projectRoot, 'registration'));
|
||||
ModuleHttp::requireDesktopAccess($projectRoot, true);
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
if ($auth->isAuthenticated()) {
|
||||
$currentUser = is_array($_SESSION['desktop_auth']['user'] ?? null) ? $_SESSION['desktop_auth']['user'] : [];
|
||||
$accountCheck = $accountGate->checkUsername((string) ($currentUser['username'] ?? ''));
|
||||
|
||||
if (!($accountCheck['allowed'] ?? false)) {
|
||||
$auth->logout();
|
||||
http_response_code(403);
|
||||
echo json_encode(['error' => (string) ($accountCheck['message'] ?? 'Dieses Konto ist noch nicht freigeschaltet.')], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$auth->shouldShowDesktop()) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['error' => 'Nicht autorisiert.'], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
$store = new LegacyModuleStore($projectRoot, MiningCheckerUserScope::current());
|
||||
$store = new LegacyModuleStore($projectRoot, UserScope::current());
|
||||
$method = strtoupper((string) ($_SERVER['REQUEST_METHOD'] ?? 'GET'));
|
||||
|
||||
if ($method === 'GET') {
|
||||
|
||||
@@ -12,6 +12,7 @@ use Desktop\AppRegistry;
|
||||
use Desktop\AppVisibility;
|
||||
use Desktop\SkinResolver;
|
||||
use Desktop\WidgetRegistry;
|
||||
use ModulesCore\ModuleRegistry;
|
||||
|
||||
session_start();
|
||||
|
||||
@@ -27,7 +28,8 @@ if ($method === 'OPTIONS') {
|
||||
|
||||
$keycloakConfig = ConfigLoader::load($projectRoot, 'keycloak');
|
||||
$auth = new KeycloakAuth($keycloakConfig);
|
||||
$registry = new AppRegistry($projectRoot . '/config/apps.php');
|
||||
$moduleRegistry = new ModuleRegistry($projectRoot . '/modules');
|
||||
$registry = new AppRegistry($projectRoot . '/config/apps.php', $moduleRegistry->desktopApps());
|
||||
$widgetRegistry = new WidgetRegistry($projectRoot . '/config/widgets.php');
|
||||
$service = new UserSelfManagementService($projectRoot);
|
||||
$registrationConfig = ConfigLoader::load($projectRoot, 'registration');
|
||||
|
||||
@@ -2,128 +2,4 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\ConfigLoader;
|
||||
use App\AccountGate;
|
||||
use App\KeycloakAuth;
|
||||
|
||||
session_start();
|
||||
|
||||
$projectRoot = dirname(__DIR__, 3);
|
||||
$auth = new KeycloakAuth(ConfigLoader::load($projectRoot, 'keycloak'));
|
||||
$accountGate = new AccountGate(ConfigLoader::load($projectRoot, 'registration'));
|
||||
|
||||
if ($auth->isAuthenticated()) {
|
||||
$currentUser = is_array($_SESSION['desktop_auth']['user'] ?? null) ? $_SESSION['desktop_auth']['user'] : [];
|
||||
$accountCheck = $accountGate->checkUsername((string) ($currentUser['username'] ?? ''));
|
||||
|
||||
if (!($accountCheck['allowed'] ?? false)) {
|
||||
$auth->logout();
|
||||
$target = (string) ($accountCheck['state'] ?? '') === 'pending'
|
||||
? '/auth/pending/?username=' . urlencode((string) ($currentUser['username'] ?? ''))
|
||||
: '/auth/inactive/?message=' . urlencode((string) ($accountCheck['message'] ?? 'Dieses Konto ist noch nicht freigeschaltet.'));
|
||||
header('Location: ' . $target, true, 302);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$auth->shouldShowDesktop()) {
|
||||
header('Location: /auth/keycloak', true, 302);
|
||||
exit;
|
||||
}
|
||||
|
||||
$assetVersion = static function (string $publicPath) use ($projectRoot): string {
|
||||
$filesystemPath = $projectRoot . '/public' . $publicPath;
|
||||
|
||||
if (!is_file($filesystemPath)) {
|
||||
return $publicPath;
|
||||
}
|
||||
|
||||
$mtime = filemtime($filesystemPath);
|
||||
|
||||
return $mtime === false ? $publicPath : $publicPath . '?v=' . $mtime;
|
||||
};
|
||||
|
||||
$sections = [
|
||||
['key' => 'overview', 'label' => 'Übersicht'],
|
||||
['key' => 'upload', 'label' => 'Upload'],
|
||||
['key' => 'measurements', 'label' => 'Mining-History'],
|
||||
['key' => 'wallet', 'label' => 'Wallet'],
|
||||
['key' => 'mining', 'label' => 'Miner-Daten'],
|
||||
['key' => 'dashboards', 'label' => 'Dashboards'],
|
||||
];
|
||||
$defaultProjectKey = getenv('MINING_CHECKER_DEFAULT_PROJECT_KEY') ?: 'doge-main';
|
||||
$activeView = trim((string) ($_GET['view'] ?? 'overview'));
|
||||
$sectionKeys = array_values(array_filter(array_map(
|
||||
static fn (mixed $section): string => is_array($section) ? trim((string) ($section['key'] ?? '')) : '',
|
||||
$sections
|
||||
)));
|
||||
|
||||
if ($sectionKeys === []) {
|
||||
$sectionKeys = ['overview'];
|
||||
}
|
||||
|
||||
if (!in_array($activeView, $sectionKeys, true)) {
|
||||
$activeView = $sectionKeys[0];
|
||||
}
|
||||
|
||||
$sectionsJson = json_encode($sections, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
?><!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Mining-Checker</title>
|
||||
<style>
|
||||
:root {
|
||||
color-scheme: light;
|
||||
--surface: rgba(255, 255, 255, 0.92);
|
||||
--line: rgba(148, 163, 184, 0.24);
|
||||
--text: #0f172a;
|
||||
--muted: #475569;
|
||||
--brand-accent: #14b8a6;
|
||||
--brand-accent-3: #0f766e;
|
||||
font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background:
|
||||
radial-gradient(circle at top left, rgba(45, 212, 191, 0.12), transparent 24%),
|
||||
linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.mining-module-shell {
|
||||
min-height: 100vh;
|
||||
padding: 18px;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="<?= htmlspecialchars($assetVersion('/assets/apps/mining-checker/app.css'), ENT_QUOTES) ?>">
|
||||
</head>
|
||||
<body data-module-debug-enabled="0">
|
||||
<div class="mining-module-shell">
|
||||
<div
|
||||
id="mining-checker-app"
|
||||
data-default-project-key="<?= htmlspecialchars($defaultProjectKey, ENT_QUOTES) ?>"
|
||||
data-api-base="/api/mining-checker/index.php/v1"
|
||||
data-active-view="<?= htmlspecialchars($activeView, ENT_QUOTES) ?>"
|
||||
data-sections-json="<?= htmlspecialchars(is_string($sectionsJson) ? $sectionsJson : '[]', ENT_QUOTES) ?>"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
||||
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
||||
<script src="<?= htmlspecialchars($assetVersion('/assets/apps/mining-checker/app.js'), ENT_QUOTES) ?>"></script>
|
||||
</body>
|
||||
</html>
|
||||
require dirname(__DIR__, 3) . '/modules/mining-checker/pages/index.php';
|
||||
|
||||
@@ -1,772 +0,0 @@
|
||||
#mining-checker-app {
|
||||
--mc-surface: var(--surface);
|
||||
--mc-surface-strong: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,252,252,0.92));
|
||||
--mc-line: var(--line);
|
||||
--mc-line-strong: color-mix(in srgb, var(--brand-accent) 28%, transparent);
|
||||
--mc-text: var(--text);
|
||||
--mc-text-muted: var(--muted);
|
||||
--mc-accent: var(--brand-accent);
|
||||
--mc-accent-strong: var(--brand-accent-3);
|
||||
--mc-danger: #d92d20;
|
||||
--mc-success: #14804a;
|
||||
--mc-warning: #b54708;
|
||||
min-height: 0;
|
||||
background: none;
|
||||
color: var(--mc-text);
|
||||
font-family: inherit;
|
||||
max-width: 100%;
|
||||
overflow-x: clip;
|
||||
}
|
||||
|
||||
#mining-checker-app,
|
||||
#mining-checker-app * {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-grid-bg {
|
||||
background: none;
|
||||
max-width: 100%;
|
||||
overflow-x: clip;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-shell {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-stack {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-panel,
|
||||
#mining-checker-app .mc-stat-card,
|
||||
#mining-checker-app .mc-dashboard-card,
|
||||
#mining-checker-app .mc-target-card,
|
||||
#mining-checker-app .mc-alert,
|
||||
#mining-checker-app .mc-empty,
|
||||
#mining-checker-app .mc-table-shell,
|
||||
#mining-checker-app .mc-display-field {
|
||||
border: 1px solid var(--mc-line);
|
||||
border-radius: 22px;
|
||||
background: var(--mc-surface);
|
||||
/* box-shadow: 0 12px 30px rgba(1, 22, 32, 0.08); */
|
||||
backdrop-filter: blur(8px);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-panel,
|
||||
#mining-checker-app .mc-dashboard-card,
|
||||
#mining-checker-app .mc-alert,
|
||||
#mining-checker-app .mc-empty,
|
||||
#mining-checker-app .mc-table-shell {
|
||||
padding: 18px 20px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-hero-top,
|
||||
#mining-checker-app .mc-inline-row,
|
||||
#mining-checker-app .mc-flex-split,
|
||||
#mining-checker-app .mc-section-head {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-hero-top,
|
||||
#mining-checker-app .mc-flex-split,
|
||||
#mining-checker-app .mc-section-head {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-hero-copy,
|
||||
#mining-checker-app .mc-hero-controls,
|
||||
#mining-checker-app .mc-panel-body,
|
||||
#mining-checker-app .mc-form,
|
||||
#mining-checker-app .mc-field,
|
||||
#mining-checker-app .mc-filter-grid,
|
||||
#mining-checker-app .mc-chart,
|
||||
#mining-checker-app .mc-target-grid {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-filter-grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-text,
|
||||
#mining-checker-app p,
|
||||
#mining-checker-app td,
|
||||
#mining-checker-app th,
|
||||
#mining-checker-app label,
|
||||
#mining-checker-app summary,
|
||||
#mining-checker-app pre {
|
||||
color: var(--mc-text-muted);
|
||||
}
|
||||
|
||||
#mining-checker-app h1,
|
||||
#mining-checker-app h2,
|
||||
#mining-checker-app h3 {
|
||||
margin: 0;
|
||||
color: var(--mc-text);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-stats-grid,
|
||||
#mining-checker-app .mc-target-grid,
|
||||
#mining-checker-app .mc-overview-grid,
|
||||
#mining-checker-app .mc-two-col,
|
||||
#mining-checker-app .mc-main-grid {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-stats-grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-overview-grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-target-grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-two-col {
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-asset-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-asset-card {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-asset-balance {
|
||||
font-size: 1.15rem;
|
||||
font-weight: 700;
|
||||
color: var(--mc-text);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-asset-list {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
min-width: 240px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-asset-row {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-asset-row strong {
|
||||
color: var(--mc-text);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-main-grid {
|
||||
grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-stat-card,
|
||||
#mining-checker-app .mc-target-card {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-stat-card {
|
||||
background: var(--mc-surface-strong);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-kicker {
|
||||
font-size: 0.76rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.18em;
|
||||
color: var(--mc-accent-strong);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-stat-value {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
line-height: 1.1;
|
||||
color: var(--mc-text);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.18em;
|
||||
border: 1px solid var(--mc-line-strong);
|
||||
background: color-mix(in srgb, var(--mc-accent) 16%, transparent);
|
||||
color: var(--mc-accent-strong);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-badge--warn {
|
||||
background: color-mix(in srgb, var(--mc-warning) 12%, transparent);
|
||||
color: var(--mc-warning);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-badge--info {
|
||||
background: color-mix(in srgb, var(--mc-accent) 16%, transparent);
|
||||
color: var(--mc-accent-strong);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-badge--danger {
|
||||
background: color-mix(in srgb, var(--mc-danger) 12%, transparent);
|
||||
color: var(--mc-danger);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-badge--success {
|
||||
background: color-mix(in srgb, var(--mc-success) 12%, transparent);
|
||||
color: var(--mc-success);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button,
|
||||
#mining-checker-app button,
|
||||
#mining-checker-app input,
|
||||
#mining-checker-app select,
|
||||
#mining-checker-app textarea {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button {
|
||||
border: 1px solid transparent;
|
||||
border-radius: 16px;
|
||||
padding: 12px 16px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
transition: 160ms ease;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button:hover {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: default;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button--primary {
|
||||
background: linear-gradient(135deg, var(--mc-accent), var(--mc-accent-strong));
|
||||
color: #05121f;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button--secondary {
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
color: var(--mc-text);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button--danger {
|
||||
background: linear-gradient(135deg, rgba(251, 113, 133, 0.92), rgba(239, 68, 68, 0.92));
|
||||
color: #fff7f7;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button--ghost {
|
||||
background: color-mix(in srgb, var(--mc-accent) 14%, transparent);
|
||||
border-color: color-mix(in srgb, var(--mc-accent) 34%, transparent);
|
||||
color: var(--mc-accent-strong);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-debug-tools {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-debug-console {
|
||||
border-color: rgba(125, 211, 252, 0.28);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-debug-view-switch {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-debug-log {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
max-height: 520px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-debug-text-console {
|
||||
max-height: 520px;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-debug-entry {
|
||||
border: 1px solid var(--mc-line);
|
||||
border-radius: 18px;
|
||||
padding: 14px 16px;
|
||||
background: color-mix(in srgb, var(--brand-accent-2) 8%, var(--mc-surface));
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-field {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-field-label {
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.18em;
|
||||
color: var(--mc-text-muted);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-input,
|
||||
#mining-checker-app .mc-select,
|
||||
#mining-checker-app .mc-textarea,
|
||||
#mining-checker-app .mc-file {
|
||||
width: 100%;
|
||||
border: 1px solid var(--mc-line);
|
||||
border-radius: 16px;
|
||||
padding: 13px 15px;
|
||||
color: var(--mc-text);
|
||||
background: rgba(255, 255, 255, 0.72);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-select option {
|
||||
color: #09111f;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-textarea {
|
||||
min-height: 120px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-input::placeholder,
|
||||
#mining-checker-app .mc-textarea::placeholder {
|
||||
color: #6d7c90;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-input:focus,
|
||||
#mining-checker-app .mc-select:focus,
|
||||
#mining-checker-app .mc-textarea:focus,
|
||||
#mining-checker-app .mc-file:focus {
|
||||
border-color: rgba(125, 211, 252, 0.5);
|
||||
box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.12);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
border: 1px solid var(--mc-line);
|
||||
border-radius: 16px;
|
||||
padding: 14px 16px;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-inline-fields {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
align-items: end;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-inline-fields > .mc-field {
|
||||
flex: 1 1 280px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-alert--error {
|
||||
border-color: rgba(251, 113, 133, 0.28);
|
||||
background: rgba(127, 29, 29, 0.35);
|
||||
color: #ffe4e6;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-alert--warning {
|
||||
border-color: rgba(245, 158, 11, 0.28);
|
||||
background: rgba(120, 53, 15, 0.34);
|
||||
color: #fef3c7;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-alert--success {
|
||||
border-color: rgba(52, 211, 153, 0.28);
|
||||
background: rgba(6, 78, 59, 0.34);
|
||||
color: #d1fae5;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-table-shell {
|
||||
overflow: auto;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-table th,
|
||||
#mining-checker-app .mc-table td {
|
||||
padding: 14px 16px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-table thead {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-empty {
|
||||
border-style: dashed;
|
||||
}
|
||||
|
||||
#mining-checker-app details {
|
||||
border: 1px solid var(--mc-line);
|
||||
border-radius: 18px;
|
||||
padding: 16px;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
#mining-checker-app pre {
|
||||
white-space: pre-wrap;
|
||||
margin: 12px 0 0;
|
||||
line-height: 1.65;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-mini-grid {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-mini-card,
|
||||
#mining-checker-app .mc-display-field {
|
||||
padding: 12px 14px;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-code-block {
|
||||
margin: 0;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid var(--mc-line);
|
||||
border-radius: 16px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
font-family: "JetBrains Mono", "SFMono-Regular", monospace;
|
||||
font-size: 0.92rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-chart svg {
|
||||
width: 100%;
|
||||
height: 220px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 80;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
background: rgba(2, 6, 23, 0.72);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-modal {
|
||||
width: min(720px, 100%);
|
||||
max-height: min(80vh, 900px);
|
||||
overflow: auto;
|
||||
padding: 24px;
|
||||
border: 1px solid var(--mc-line);
|
||||
border-radius: 28px;
|
||||
background: rgba(9, 17, 31, 0.96);
|
||||
box-shadow: 0 28px 60px rgba(0, 0, 0, 0.34);
|
||||
backdrop-filter: blur(14px);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-chart path,
|
||||
#mining-checker-app .mc-chart polyline,
|
||||
#mining-checker-app .mc-chart line,
|
||||
#mining-checker-app .mc-chart rect {
|
||||
vector-effect: non-scaling-stroke;
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
#mining-checker-app .mc-hero-top,
|
||||
#mining-checker-app .mc-inline-row,
|
||||
#mining-checker-app .mc-flex-split,
|
||||
#mining-checker-app .mc-section-head {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-main-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-shell {
|
||||
width: min(100% - 10px, 1360px);
|
||||
padding: 8px 0 20px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-stack {
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-hero,
|
||||
#mining-checker-app .mc-panel,
|
||||
#mining-checker-app .mc-dashboard-card,
|
||||
#mining-checker-app .mc-alert,
|
||||
#mining-checker-app .mc-empty,
|
||||
#mining-checker-app .mc-table-shell {
|
||||
padding: 14px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-title {
|
||||
font-size: clamp(1.45rem, 8vw, 2.15rem);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-hero-copy {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-hero-copy p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-hero-controls {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-home-link {
|
||||
justify-self: stretch;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-tabs {
|
||||
flex-wrap: nowrap;
|
||||
gap: 8px;
|
||||
margin: 12px -4px 0;
|
||||
padding: 0 4px 4px;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button {
|
||||
padding: 10px 12px;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button--tab {
|
||||
flex: 0 0 auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-table th,
|
||||
#mining-checker-app .mc-table td {
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-modal {
|
||||
max-height: min(92vh, 900px);
|
||||
padding: 16px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
#mining-checker-app,
|
||||
#mining-checker-app * {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
#mining-checker-app {
|
||||
min-height: 100vh;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-grid-bg {
|
||||
overflow-x: hidden;
|
||||
background-size: 18px 18px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-shell {
|
||||
width: 100%;
|
||||
padding: 0 0 16px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-stack {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-hero,
|
||||
#mining-checker-app .mc-panel,
|
||||
#mining-checker-app .mc-dashboard-card,
|
||||
#mining-checker-app .mc-alert,
|
||||
#mining-checker-app .mc-empty {
|
||||
width: 100%;
|
||||
border-radius: 18px;
|
||||
padding: 14px;
|
||||
box-shadow: 0 14px 32px rgba(0, 0, 0, 0.16);
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-hero {
|
||||
border-radius: 0 0 18px 18px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-panel,
|
||||
#mining-checker-app .mc-dashboard-card,
|
||||
#mining-checker-app .mc-alert,
|
||||
#mining-checker-app .mc-empty,
|
||||
#mining-checker-app .mc-table-shell {
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-title,
|
||||
#mining-checker-app .mc-hero-copy p {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-hero-top {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-kicker {
|
||||
font-size: 0.68rem;
|
||||
letter-spacing: 0.14em;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-tabs {
|
||||
margin: 10px -6px 0;
|
||||
padding: 0 6px 6px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button {
|
||||
min-height: 38px;
|
||||
padding: 8px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-button:hover {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-stats-grid,
|
||||
#mining-checker-app .mc-target-grid,
|
||||
#mining-checker-app .mc-overview-grid,
|
||||
#mining-checker-app .mc-two-col,
|
||||
#mining-checker-app .mc-main-grid,
|
||||
#mining-checker-app .mc-filter-grid,
|
||||
#mining-checker-app .mc-mini-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-stat-card,
|
||||
#mining-checker-app .mc-target-card,
|
||||
#mining-checker-app .mc-mini-card,
|
||||
#mining-checker-app .mc-display-field {
|
||||
padding: 12px;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-stat-value {
|
||||
font-size: clamp(1.45rem, 8vw, 1.85rem);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#mining-checker-app h2 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
#mining-checker-app h3 {
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-text,
|
||||
#mining-checker-app p,
|
||||
#mining-checker-app td,
|
||||
#mining-checker-app th,
|
||||
#mining-checker-app label,
|
||||
#mining-checker-app summary,
|
||||
#mining-checker-app pre {
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-input,
|
||||
#mining-checker-app .mc-select,
|
||||
#mining-checker-app .mc-textarea,
|
||||
#mining-checker-app .mc-file {
|
||||
min-width: 0;
|
||||
padding: 10px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-inline-fields,
|
||||
#mining-checker-app .mc-debug-tools,
|
||||
#mining-checker-app .mc-debug-view-switch {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-inline-fields > .mc-field {
|
||||
flex-basis: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-badge {
|
||||
padding: 7px 10px;
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-table-shell {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
border-radius: 16px;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-table {
|
||||
max-width: none;
|
||||
min-width: 640px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-table th,
|
||||
#mining-checker-app .mc-table td {
|
||||
padding: 9px 10px;
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-chart svg {
|
||||
height: 180px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-modal-backdrop {
|
||||
align-items: stretch;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#mining-checker-app .mc-modal {
|
||||
width: 100%;
|
||||
max-height: calc(100vh - 16px);
|
||||
padding: 14px;
|
||||
border-radius: 18px;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1035,29 +1035,20 @@ if (payloadNode) {
|
||||
}
|
||||
|
||||
const moduleHost = node.querySelector('.window-module-host');
|
||||
if (moduleHost && definition.content_mode === 'native-module' && definition.app_id === 'mining-checker') {
|
||||
const moduleOptions = definition.module_options || {};
|
||||
if (typeof window.initMiningCheckerApp === 'function') {
|
||||
window.initMiningCheckerApp(moduleHost, {
|
||||
apiBase: '/api/mining-checker/index.php/v1',
|
||||
defaultProjectKey: moduleOptions.default_project_key || 'doge-main',
|
||||
activeView: moduleOptions.active_view || 'overview',
|
||||
sections: Array.isArray(moduleOptions.sections) ? moduleOptions.sections : [],
|
||||
moduleDebugEnabled: false,
|
||||
});
|
||||
} else {
|
||||
moduleHost.innerHTML = '<div class="window-module-error">Mining-Checker Assets konnten nicht initialisiert werden.</div>';
|
||||
}
|
||||
}
|
||||
if (moduleHost && definition.content_mode === 'native-module') {
|
||||
const nativeModule = definition.native_module || {};
|
||||
const initializer = nativeModule.initializer;
|
||||
const baseOptions = nativeModule.options && typeof nativeModule.options === 'object' ? nativeModule.options : {};
|
||||
const moduleOptions = {
|
||||
...baseOptions,
|
||||
apiBase: baseOptions.apiBase || settingsApi,
|
||||
activeSkin,
|
||||
};
|
||||
|
||||
if (moduleHost && definition.content_mode === 'native-module' && definition.app_id === 'user-self-management') {
|
||||
if (typeof window.initUserSelfManagementApp === 'function') {
|
||||
window.initUserSelfManagementApp(moduleHost, {
|
||||
apiBase: settingsApi,
|
||||
activeSkin,
|
||||
});
|
||||
if (typeof initializer === 'string' && typeof window[initializer] === 'function') {
|
||||
window[initializer](moduleHost, moduleOptions);
|
||||
} else {
|
||||
moduleHost.innerHTML = '<div class="window-module-error">User Self Management konnte nicht initialisiert werden.</div>';
|
||||
moduleHost.innerHTML = `<div class="window-module-error">${escapeHtml(definition.title || 'Modul')} konnte nicht initialisiert werden.</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1113,6 +1104,7 @@ if (payloadNode) {
|
||||
entry_route: app.entry_route || '',
|
||||
content_mode: app.content_mode || 'summary',
|
||||
module_options: app.module_options || null,
|
||||
native_module: app.native_module || null,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
53
public/module-assets/index.php
Normal file
53
public/module-assets/index.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/src/App/bootstrap.php';
|
||||
|
||||
use ModulesCore\ModuleRegistry;
|
||||
|
||||
$projectRoot = dirname(__DIR__, 2);
|
||||
$module = trim((string) ($_GET['module'] ?? ''));
|
||||
$path = trim((string) ($_GET['path'] ?? ''));
|
||||
|
||||
if ($module === '' || $path === '' || str_contains($path, '..')) {
|
||||
http_response_code(400);
|
||||
exit('Invalid module asset request.');
|
||||
}
|
||||
|
||||
$registry = new ModuleRegistry($projectRoot . '/modules');
|
||||
$modulePath = $registry->modulePath($module);
|
||||
|
||||
if ($modulePath === null) {
|
||||
http_response_code(404);
|
||||
exit('Module not found.');
|
||||
}
|
||||
|
||||
$assetPath = realpath($modulePath . '/' . ltrim($path, '/'));
|
||||
$allowedRoot = realpath($modulePath);
|
||||
|
||||
if ($assetPath === false || $allowedRoot === false || !str_starts_with($assetPath, $allowedRoot . DIRECTORY_SEPARATOR) || !is_file($assetPath)) {
|
||||
http_response_code(404);
|
||||
exit('Asset not found.');
|
||||
}
|
||||
|
||||
$extension = strtolower(pathinfo($assetPath, PATHINFO_EXTENSION));
|
||||
$contentType = match ($extension) {
|
||||
'css' => 'text/css; charset=utf-8',
|
||||
'js' => 'application/javascript; charset=utf-8',
|
||||
'json' => 'application/json; charset=utf-8',
|
||||
'svg' => 'image/svg+xml',
|
||||
'png' => 'image/png',
|
||||
'jpg', 'jpeg' => 'image/jpeg',
|
||||
'gif' => 'image/gif',
|
||||
'webp' => 'image/webp',
|
||||
default => 'application/octet-stream',
|
||||
};
|
||||
|
||||
$mtime = filemtime($assetPath);
|
||||
if ($mtime !== false) {
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $mtime) . ' GMT');
|
||||
}
|
||||
header('Content-Type: ' . $contentType);
|
||||
header('Cache-Control: public, max-age=300');
|
||||
readfile($assetPath);
|
||||
Reference in New Issue
Block a user