From 34f3c4ae7e2c26f29f664a4b73bc09ad55fa465a Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Mon, 16 Nov 2026 16:34:33 +0100 Subject: [PATCH 1/3] Document 1.0.1.1 SHOP discovery and general-commerce migration plan --- docs/design/1.0.1.1-shop.md | 68 +++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 docs/design/1.0.1.1-shop.md diff --git a/docs/design/1.0.1.1-shop.md b/docs/design/1.0.1.1-shop.md new file mode 100644 index 00000000..9f52f6fb --- /dev/null +++ b/docs/design/1.0.1.1-shop.md @@ -0,0 +1,68 @@ +# 1.0.1.1 SHOP — discovery and implementation plan + +Status: discovery / open implementation PR. This document does not claim that the replacement shop, payment adapter or vendor emails are installed. + +## Owner decisions + +- Use a general webshop at `shop.dunerealms.com` for hosting, physical merchandise (including sashes), digital services and optional item/kit codes. +- Keep the current Azuriom shop, its files, orders, configuration and database. Latest instruction: remove its MAIN MENU link only; do not deactivate it yet. +- Do not build a direct dependency between two shops. The new shop can use existing one-time code/delivery services as a fulfilment adapter. +- Existing customer identities, permissions, order histories and paid entitlements must remain intact. + +## Findings + +The current shop is Azuriom with its Shop plugin. Azuriom's official Shop repository describes in-game sales and extensible payment methods. It is useful to retain, but a Minecraft-centred checkout is not the desired basis for hosting and shipped merchandise. + +osCommerce is a plausible replacement candidate because it is a general storefront. Its official V4 repository includes the installation process and requires a separately created database. The production PHP runtime must be checked against the selected supported release; the website host currently uses PHP 8.5, which must not be assumed compatible. Official 2024 documentation confirms 4.13 support through PHP 8.2; a newer official product page mentions PHP 8.3. Those statements are not proof of PHP 8.5 support. + +No first-party Minecraft bridge for osCommerce was verified. We do not need one if our existing code fulfilment remains the separate game adapter. + +Official sources checked 16 November 2026: + +- [osCommerce V4 source and installation](https://github.com/osCommerce/osCommerce-V4) +- [Official download and hosting requirements entry point](https://www.oscommerce.com/download-oscommerce) +- [Official PHP compatibility explanation](https://www.oscommerce.com/blog/success-case-php-version-requirements-for-oscommerce-4) +- [Official osCommerce platform description](https://www.oscommerce.com/index.php?cPath=21) +- [osCommerce PayPal API/webhook documentation](https://www.oscommerce.com/blog/new-paypal-module-latest-api-2-0-configuration-in-the-advanced-variant-for-oscommerce-4-based-systems) +- [Current Azuriom Shop source](https://github.com/Azuriom/Plugin-Shop) + +## Fulfilment types + +| Type | After verified payment | Completion | +| --- | --- | --- | +| Physical merchandise | Queue an order for the configured vendor | Dispatch/tracking recorded, customer notified | +| Hosting | Queue provisioning or an authorised manual work item | Service activated and customer notified | +| Digital service | Queue its defined service workflow | Deliverable confirmed | +| Kit/item code | Issue one matching entitlement through the existing system | Code redeemed once; game delivery independently confirmed | + +## Physical order flow + +Product/variant/stock and personalisation → delivery address → shipping quote → checkout → verified paid order → vendor notification → packing → dispatch → tracking → completion. Retain refund, cancellation and return history. A vendor receives only the information needed for their allocated order lines, not unrestricted customer access. + +Vendor notification is automatic after payment is confirmed, never merely because a draft order exists. Use an outbox with unique order/vendor/event keys so retries do not send duplicate orders. Record acceptance, dispatch and tracking separately from payment status. Actual vendor destinations still need configuration; no emails are sent by this discovery work. + +## Existing code bridge + +A verified paid order line creates at most one entitlement. Bind it to the correct purchaser/player identity, record an immutable shop/order/line reference, and use idempotency keys. A repeated webhook, refresh or retry must not mint another code or deliver twice. Keep the distinction between paid, code issued, redeemed and game-delivered states. + +Proposed new display prefixes previously agreed: KIT-, UP-, CLAN-, COM-. Existing DRK/DRU and other valid codes must remain redeemable until compatible migration is implemented. Do not assume a label change implements a new backend format. Physical merchandise and hosting do not use game-code fulfilment. + +## Proposed batches + +1. Inspect current host/storage/PHP and current shop data; install a separate supported osCommerce runtime/database at the selected hostname. Do not reuse or overwrite the old shop database. +2. Configure TLS, restricted administration, backups and a non-live staging checkout. Verify scheduled workers, mail and certificate renewal. +3. Design the catalogue, physical shipping, variants/personalisation and vendor order workflow. +4. Add identity/account integration and the reusable paid-order/code adapter. +5. Test payment success/failure/refund, duplicate events, vendor retry, dispatch and one-time redemption. Use test payment mode and fixtures; do not create real purchases or send vendor mail during testing. +6. Review the concrete storefront and transaction flows before enabling live payments and replacing the public Shop entry. + +## Open implementation questions + +- Exact current supported osCommerce release and PHP/runtime requirements, resource footprint and maintenance path. +- Vendor destinations, product catalogue, shipping origins/regions/rates, stock and personalisation fields. +- Payment providers, tax/invoice configuration, refund/return terms and hosting provisioning adapter. +- DNS for shop.dunerealms.com and which existing SSO capability can be reused safely. + +## Separation from other work + +The ongoing clan/company/Boards work remains under PR #337. This SHOP PR remains open until its implementation and review are finished. Shop discovery does not authorize changes to voting, account ownership, organisation entitlements or bank balances. From 7ab013bd537eea6561fc2be7ac5ca040dcf697f4 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 16 Nov 2026 16:21:45 +0000 Subject: [PATCH 2/3] Install independent osCommerce portal with central account linking --- website/node/integration-sso.mjs | 2 +- website/ops/oscommerce/DuneAccount.php | 88 +++++++++++++++++++ website/ops/oscommerce/README.md | 14 +++ website/ops/oscommerce/dune-oscommerce.css | 11 +++ website/ops/oscommerce/oscommerce-http.conf | 6 ++ website/ops/oscommerce/oscommerce-https.conf | 44 ++++++++++ website/ops/oscommerce/oscommerce-pool.conf | 22 +++++ .../oscommerce/publish-oscommerce-portal.py | 24 +++++ website/ops/oscommerce/setup-osc-account.py | 14 +++ website/tests/oscommerce-sso.test.mjs | 34 +++++++ website/web/oscommerce-embed.js | 1 + website/web/oscommerce-inner.js | 1 + website/web/portal-navigation.js | 10 +-- website/web/shop-oscommerce.html | 1 + 14 files changed, 266 insertions(+), 6 deletions(-) create mode 100644 website/ops/oscommerce/DuneAccount.php create mode 100644 website/ops/oscommerce/README.md create mode 100644 website/ops/oscommerce/dune-oscommerce.css create mode 100644 website/ops/oscommerce/oscommerce-http.conf create mode 100644 website/ops/oscommerce/oscommerce-https.conf create mode 100644 website/ops/oscommerce/oscommerce-pool.conf create mode 100644 website/ops/oscommerce/publish-oscommerce-portal.py create mode 100644 website/ops/oscommerce/setup-osc-account.py create mode 100644 website/tests/oscommerce-sso.test.mjs create mode 100644 website/web/oscommerce-embed.js create mode 100644 website/web/oscommerce-inner.js create mode 100644 website/web/shop-oscommerce.html diff --git a/website/node/integration-sso.mjs b/website/node/integration-sso.mjs index 0389f5c7..3b145b56 100644 --- a/website/node/integration-sso.mjs +++ b/website/node/integration-sso.mjs @@ -8,7 +8,7 @@ import {accessFor} from './permissions.mjs'; const hash=s=>createHash('sha256').update(s).digest('hex'); const json=(body,status=200)=>Response.json(body,{status,headers:{'Cache-Control':'no-store'}}); export function createIntegrationSSO(db,settings={}){ - const clients={git:'https://www.dunerealms.com/git/sso/callback',mybb:'https://forums.dunerealms.com/dune-sso.php',osticket:'https://support.dunerealms.com/dune-sso.php',shop:'https://cp.dunerealms.com/store/dune-login'}; + const clients={git:'https://www.dunerealms.com/git/sso/callback',mybb:'https://forums.dunerealms.com/dune-sso.php',osticket:'https://support.dunerealms.com/dune-sso.php',shop:'https://cp.dunerealms.com/store/dune-login',oscommerce:'https://shop.dunerealms.com/dune-login.php'}; return async request=>{ const url=new URL(request.url),client=url.searchParams.get('client'); if(url.pathname==='/sso/authorize'){ diff --git a/website/ops/oscommerce/DuneAccount.php b/website/ops/oscommerce/DuneAccount.php new file mode 100644 index 00000000..81930418 --- /dev/null +++ b/website/ops/oscommerce/DuneAccount.php @@ -0,0 +1,88 @@ +$expires,'path'=>'/','secure'=>true,'httponly'=>true,'samesite'=>'Lax']); } + private static function api(string $operation,array $payload):array { + $config=json_decode(file_get_contents('/home/dunerealms/.config/integrations.json'),true,8,JSON_THROW_ON_ERROR); + $curl=curl_init('http://127.0.0.1:3003/internal/integrations/'.$operation); + curl_setopt_array($curl,[CURLOPT_POST=>true,CURLOPT_POSTFIELDS=>json_encode($payload),CURLOPT_HTTPHEADER=>['Content-Type: application/json','Authorization: Bearer '.$config['secret']],CURLOPT_RETURNTRANSFER=>true,CURLOPT_TIMEOUT=>6]); + $body=curl_exec($curl);$status=curl_getinfo($curl,CURLINFO_HTTP_CODE);curl_close($curl); + if($status!==200) throw new \yii\web\HttpException($status===401?401:503,'DuneRealms sign-in is unavailable. Please sign in again.'); + return json_decode($body,true,32,JSON_THROW_ON_ERROR); + } + public function bootstrap($app):void { $app->on(\yii\base\Application::EVENT_BEFORE_REQUEST,fn()=>self::handle($app)); } + private static function redirect($app,string $url):never { $app->response->redirect($url,303)->send();$app->end();exit; } + private static function start($app,string $next='/catalog/'):never { + $state=self::token();$nonce=self::token(); + $app->db->createCommand()->delete('dune_sso_states','expires_at < :now',[':now'=>time()])->execute(); + $app->db->createCommand()->insert('dune_sso_states',['state_hash'=>hash('sha256',$state),'nonce_hash'=>hash('sha256',$nonce),'next_path'=>$next,'expires_at'=>time()+300])->execute(); + self::cookie('__Host-dune_osc_state',$nonce,time()+300); + $url='https://cp.dunerealms.com/sso/authorize?client=oscommerce&state='.rawurlencode($state); + if(($_SERVER['HTTP_SEC_FETCH_DEST']??'')==='iframe'){ + $js=json_encode(['type'=>'dune-shop-signin','url'=>$url],JSON_HEX_TAG|JSON_HEX_AMP); + $app->response->format=\yii\web\Response::FORMAT_HTML; + $parent='https://shop.dunerealms.com';$ref=parse_url($_SERVER['HTTP_REFERER']??''); + if(($ref['scheme']??'')==='https'&&in_array($ref['host']??'',['www.dunerealms.com','dunerealms.com','cp.dunerealms.com','shop.dunerealms.com'],true))$parent='https://'.$ref['host']; + $app->response->content='

Continue with your DuneRealms account

'; + $app->response->send();$app->end();exit; + } + self::redirect($app,$url); + } + private static function synchronize($app,array $identity):int { + if(!preg_match('/^[a-f0-9-]{36}$/i',$identity['id']??'')||!preg_match('/^[a-f0-9]{64}$/',$identity['sessionRef']??''))throw new \yii\web\ForbiddenHttpException('Invalid account identity'); + $db=$app->db;$transaction=$db->beginTransaction(); + try{ + $id=$db->createCommand('SELECT customer_id FROM dune_account_links WHERE account_id=:id FOR UPDATE',[':id'=>$identity['id']])->queryScalar(); + $email=$identity['id'].'@accounts.dunerealms.invalid'; + if(!$id){ + $db->createCommand("SET SESSION sql_mode=''")->execute(); + $db->createCommand()->insert('customers',['customers_firstname'=>mb_substr($identity['username']??'Player',0,32),'customers_lastname'=>'','customers_email_address'=>$email,'customers_password'=>password_hash(bin2hex(random_bytes(32)),PASSWORD_BCRYPT),'customers_status'=>1,'platform_id'=>\common\classes\platform::currentId()])->execute(); + $id=(int)$db->getLastInsertID(); + $db->createCommand()->insert('dune_account_links',['account_id'=>$identity['id'],'customer_id'=>$id])->execute(); + $db->createCommand()->insert('customers_info',['customers_info_id'=>$id,'customers_info_date_account_created'=>gmdate('Y-m-d H:i:s')])->execute(); + } + $db->createCommand()->update('customers',['customers_firstname'=>mb_substr($identity['username']??'Player',0,32)],['customers_id'=>$id])->execute(); + $transaction->commit();return (int)$id; + }catch(\Throwable $e){$transaction->rollBack();throw $e;} + } + private static function handle($app):void { + $app->response->headers->set('Referrer-Policy','no-referrer'); + $path=parse_url($_SERVER['REQUEST_URI']??'/',PHP_URL_PATH); + if($path==='/dune-login.php'){ + if(!isset($_GET['code']))self::start($app); + $state=$_GET['state']??'';$nonce=$_COOKIE['__Host-dune_osc_state']??''; + if(!is_string($state)||!is_string($nonce)||!preg_match('/^[A-Za-z0-9_-]{43}$/',$state)||!preg_match('/^[A-Za-z0-9_-]{43}$/',$nonce))throw new \yii\web\ForbiddenHttpException('Invalid sign-in state'); + $row=$app->db->createCommand('SELECT * FROM dune_sso_states WHERE state_hash=:state AND nonce_hash=:nonce AND expires_at>=:now',[':state'=>hash('sha256',$state),':nonce'=>hash('sha256',$nonce),':now'=>time()])->queryOne(); + if(!$row)throw new \yii\web\ForbiddenHttpException('Expired or already used sign-in state'); + $removed=$app->db->createCommand()->delete('dune_sso_states',['state_hash'=>$row['state_hash'],'nonce_hash'=>$row['nonce_hash']])->execute(); + if($removed!==1)throw new \yii\web\ForbiddenHttpException('Sign-in already used'); + $identity=self::api('redeem',['client'=>'oscommerce','code'=>$_GET['code']]); + $id=self::synchronize($app,$identity);$token=self::token(); + $app->db->createCommand()->insert('dune_sso_sessions',['token_hash'=>hash('sha256',$token),'account_id'=>$identity['id'],'session_ref'=>$identity['sessionRef'],'expires_at'=>time()+43200])->execute(); + self::cookie('__Host-dune_oscommerce',$token,time()+43200);self::cookie('__Host-dune_osc_state','',time()-3600); + self::redirect($app,'https://shop.dunerealms.com/'); + } + $token=$_COOKIE['__Host-dune_oscommerce']??'';$identity=null; + if(is_string($token)&&preg_match('/^[A-Za-z0-9_-]{43}$/',$token)){ + $row=$app->db->createCommand('SELECT account_id,session_ref FROM dune_sso_sessions WHERE token_hash=:token AND expires_at>:now',[':token'=>hash('sha256',$token),':now'=>time()])->queryOne(); + if($row){ + try{$identity=self::api('identity',['sessionRef'=>$row['session_ref']]);}catch(\yii\web\HttpException $e){if($e->statusCode!==401)throw $e;} + if(($identity['id']??null)!==$row['account_id'])$identity=null; + } + } + if($identity){ + $id=self::synchronize($app,$identity); + if((int)$app->user->id!==$id){ + if(!$app->user->isGuest){$app->user->logout(false);global $cart;if(is_object($cart)&&is_callable([$cart,'reset']))$cart->reset();} + $app->session->regenerateID(true); + $customer=new \common\components\Customer(\common\components\Customer::LOGIN_WITHOUT_CHECK); + if(!$customer->loginCustomer($identity['id'].'@accounts.dunerealms.invalid',$id))throw new \yii\web\ForbiddenHttpException('Account link failed'); + } + }elseif(!$app->user->isGuest){$app->user->logout(false);self::cookie('__Host-dune_oscommerce','',time()-3600);} + if(preg_match('#^/catalog/account/(login|create|password|password-forgotten)#',$path))self::start($app); + if(preg_match('#^/catalog/account/?$#',$path))self::redirect($app,'https://cp.dunerealms.com/'); + if(preg_match('#^/catalog/checkout#',$path)&&!$identity)self::start($app,$path); + } +} diff --git a/website/ops/oscommerce/README.md b/website/ops/oscommerce/README.md new file mode 100644 index 00000000..966a273c --- /dev/null +++ b/website/ops/oscommerce/README.md @@ -0,0 +1,14 @@ +# Independent osCommerce shop + +Host: https://shop.dunerealms.com/ +Portal: /var/www/dunerealms-shop-portal/index.html +Application: /home/dunerealms/apps/oscommerce (official osCommerce V4 commit 48d31a36) +Database: dunerealms_oscommerce on the existing MySQL service. Azuriom and dunerealms_store are preserved. + +The portal clones the existing public shop shell and embeds /catalog/. Header/footer assets stay central. The original /shop.html embed is unchanged. + +Frontend account linking uses the existing API with a dedicated oscommerce SSO client and an opaque host-only cookie. Customer records map by central account UUID. One-time codes, browser-bound state, expiry and central-session revalidation are enforced. Native registration/password endpoints redirect to the central account. No API permission or role synchronization is performed; native osCommerce backend permissions remain authoritative. + +PHP-FPM pool and TLS vhost are separate from Azuriom. Installer paths, .git, configuration, SQL and downloads are denied at the web server. No credentials belong in this directory. + +Backend theme proposal: Tabler (https://tabler.io), MIT licensed. This requires an adapter; it has not been installed over the native backend. diff --git a/website/ops/oscommerce/dune-oscommerce.css b/website/ops/oscommerce/dune-oscommerce.css new file mode 100644 index 00000000..ea99a8ff --- /dev/null +++ b/website/ops/oscommerce/dune-oscommerce.css @@ -0,0 +1,11 @@ +:root{color-scheme:dark;--dune-ink:#0b2019;--dune-panel:#15352a;--dune-gold:#e7cc83;--dune-line:#8d7946;--dune-text:#eee6d3} +html,body{background:var(--dune-ink)!important;color:var(--dune-text)!important;font-family:Inter,Arial,sans-serif!important} +body{margin:0!important}.main-content{background:transparent!important;min-height:35vh;padding:28px 0!important}.main-width{max-width:1340px!important;margin:auto!important} +.dune-shop-header{position:relative;background:linear-gradient(120deg,#153e2ee8,#091b16f7);border-bottom:1px solid var(--dune-line);padding:24px 4vw 20px} +.dune-shop-header .wordmark{display:block;text-align:center;margin:auto auto 20px}.dune-shop-header .masthead-logo{width:360px;max-width:80vw;height:auto} +.dune-shop-header nav{display:flex;justify-content:center;flex-wrap:wrap;gap:8px}.dune-shop-header nav a{display:flex;gap:7px;align-items:center;border:1px solid #756b3b;border-radius:9px;padding:9px 12px;color:var(--dune-text)!important;text-decoration:none;background:#0b211bdc;font-size:13px}.dune-shop-header nav a:hover{background:#284c38;border-color:#e7cc83;box-shadow:0 0 15px #cda14c20}.dune-shop-header nav img{width:34px;height:34px;object-fit:contain} +.dune-shop-hero{max-width:1340px;margin:26px auto 0;display:flex;align-items:center;gap:26px;border:1px solid var(--dune-line);border-radius:18px;padding:30px 38px;background:radial-gradient(ellipse at 15% 25%,#315a3c99,transparent 60%),linear-gradient(125deg,#193b2c,#10271f);box-shadow:0 12px 30px #0003}.dune-shop-hero img{width:110px;height:110px;object-fit:contain;filter:drop-shadow(0 6px 12px #0008)}.dune-shop-hero p{margin:0;color:#bca15f;font-size:12px;letter-spacing:.16em;text-transform:uppercase}.dune-shop-hero h1{color:var(--dune-gold);font-size:38px;margin:8px 0}.dune-shop-hero small{color:#cbd8c9;font-size:15px} +.dune-shop-toolbar{max-width:1340px;margin:16px auto;display:flex;gap:12px;justify-content:flex-end;flex-wrap:wrap}.dune-shop-toolbar a,.dune-shop-link{border:1px solid var(--dune-line);border-radius:8px;background:#193a2d;color:var(--dune-gold)!important;padding:10px 16px;text-decoration:none;font-weight:600} +.main-content a{color:var(--dune-gold)}.main-content h1,.main-content h2,.main-content h3,.main-content h4{color:var(--dune-gold)!important}.main-content .item,.main-content .product-item,.main-content .product-listing-item,.main-content .w-block{background:var(--dune-panel)!important;border-color:#456247!important;border-radius:12px}.main-content input,.main-content select,.main-content textarea{background:#0b241c!important;color:#eee6d3!important;border:1px solid #63734e!important;border-radius:6px}.main-content .btn,.main-content button,.main-content input[type=submit]{background:linear-gradient(#254b35,#173829)!important;color:var(--dune-gold)!important;border:1px solid var(--dune-line)!important;border-radius:8px!important;box-shadow:0 3px 8px #0003}.main-content .btn:hover,.main-content button:hover{filter:brightness(1.15)} +.dune-shop-footer{margin-top:32px;padding:30px 4vw;border-top:1px solid #63734e;background:#091c16;text-align:center;color:#b8cbb6;font-size:13px}.dune-shop-footer a{color:var(--dune-gold);margin:0 10px}.dune-shop-footer p{margin:12px 0 0;font-size:12px}.dune-shop-footer strong{color:var(--dune-gold);font-size:17px}.dune-shop-powered{opacity:.65;font-size:11px!important} +@media(max-width:700px){.dune-shop-hero{margin:16px 12px 0;padding:20px;gap:16px}.dune-shop-hero img{width:70px;height:70px}.dune-shop-hero h1{font-size:28px}.dune-shop-toolbar{margin:16px 12px;justify-content:center}.main-content{padding:18px 12px!important}.dune-shop-header nav a{padding:7px;font-size:11px}.dune-shop-header nav img{width:26px;height:26px}} diff --git a/website/ops/oscommerce/oscommerce-http.conf b/website/ops/oscommerce/oscommerce-http.conf new file mode 100644 index 00000000..a10a18bf --- /dev/null +++ b/website/ops/oscommerce/oscommerce-http.conf @@ -0,0 +1,6 @@ +server { + listen 80; listen [::]:80; + server_name shop.dunerealms.com; + location ^~ /.well-known/acme-challenge/ { root /var/www/dunerealms-acme; try_files $uri =404; } + location / { return 301 https://shop.dunerealms.com$request_uri; } +} diff --git a/website/ops/oscommerce/oscommerce-https.conf b/website/ops/oscommerce/oscommerce-https.conf new file mode 100644 index 00000000..8eb50191 --- /dev/null +++ b/website/ops/oscommerce/oscommerce-https.conf @@ -0,0 +1,44 @@ +server { + listen 443 ssl; listen [::]:443 ssl; http2 on; + server_name shop.dunerealms.com; + ssl_certificate /etc/letsencrypt/live/dunerealms-shop/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/dunerealms-shop/privkey.pem; + ssl_protocols TLSv1.2 TLSv1.3; + root /home/dunerealms/apps/oscommerce; + index index.php; + client_max_body_size 20m; + add_header X-Content-Type-Options nosniff always; + add_header Referrer-Policy strict-origin-when-cross-origin always; + add_header Strict-Transport-Security "max-age=15552000" always; + add_header Content-Security-Policy "frame-ancestors 'self' https://www.dunerealms.com https://dunerealms.com https://cp.dunerealms.com" always; + location = / { root /var/www/dunerealms-shop-portal; try_files /index.html =404; default_type text/html; } + location = /catalog { return 308 /catalog/; } + location = /catalog/index.php { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /home/dunerealms/apps/oscommerce/index.php; + fastcgi_param SCRIPT_NAME /catalog/index.php; + fastcgi_param HTTPS on; + fastcgi_pass unix:/run/php/dunerealms-oscommerce.sock; + fastcgi_read_timeout 100s; + } + location ~ /(?:\.|lib/|sql/|includes/|install/|documents/|download/) { return 404; } + location ~ ^/(?:index|admin/index|dune-login)\.php$ { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param HTTPS on; + fastcgi_pass unix:/run/php/dunerealms-oscommerce.sock; + fastcgi_read_timeout 100s; + } + location ~ \.(?:php|sql|ini|log|bak|conf)$ { return 404; } + location /catalog/ { alias /home/dunerealms/apps/oscommerce/; try_files $uri $uri/ @oscommerce_front; } + location @oscommerce_front { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /home/dunerealms/apps/oscommerce/index.php; + fastcgi_param SCRIPT_NAME /catalog/index.php; + fastcgi_param HTTPS on; + fastcgi_pass unix:/run/php/dunerealms-oscommerce.sock; + fastcgi_read_timeout 100s; + } + location /admin/ { try_files $uri $uri/ /admin/index.php?$query_string; } + location / { try_files $uri $uri/ /index.php?$query_string; } +} diff --git a/website/ops/oscommerce/oscommerce-pool.conf b/website/ops/oscommerce/oscommerce-pool.conf new file mode 100644 index 00000000..26368535 --- /dev/null +++ b/website/ops/oscommerce/oscommerce-pool.conf @@ -0,0 +1,22 @@ +[dunerealms-oscommerce] +user = dunerealms +group = dunerealms +listen = /run/php/dunerealms-oscommerce.sock +listen.owner = www-data +listen.group = www-data +listen.mode = 0660 +pm = ondemand +pm.max_children = 3 +pm.process_idle_timeout = 20s +pm.max_requests = 300 +php_admin_value[memory_limit] = 512M +php_admin_value[upload_max_filesize] = 16M +php_admin_value[post_max_size] = 20M +php_admin_value[max_execution_time] = 90 +php_admin_flag[display_errors] = off +php_admin_flag[log_errors] = on +php_admin_value[error_log] = /var/log/php8.5-oscommerce.log +php_admin_value[error_reporting] = 22527 +php_admin_value[session.cookie_httponly] = 1 +php_admin_value[session.cookie_secure] = 1 +php_admin_value[session.cookie_samesite] = Lax diff --git a/website/ops/oscommerce/publish-oscommerce-portal.py b/website/ops/oscommerce/publish-oscommerce-portal.py new file mode 100644 index 00000000..83babe40 --- /dev/null +++ b/website/ops/oscommerce/publish-oscommerce-portal.py @@ -0,0 +1,24 @@ +from pathlib import Path +import re,subprocess,urllib.request,urllib.parse +app=Path('/home/dunerealms/apps/oscommerce');target=Path('/var/www/dunerealms-shop-portal');target.mkdir(exist_ok=True) +html=urllib.request.urlopen('https://www.dunerealms.com/shop.html',timeout=30).read().decode() +html=re.sub(r'(]*\bsrc=")[^"]+',r'\1https://shop.dunerealms.com/catalog/',html,count=1) +html=html.replace('src="/shop-embed.js"','src="https://shop.dunerealms.com/oscommerce-embed.js"') +def absolute(m): + attr,value=m.group(1),m.group(2) + if value.startswith(('#','data:','mailto:','tel:','javascript:')):return m.group(0) + if not re.match(r'^https?://',value):value=urllib.parse.urljoin('https://www.dunerealms.com/shop.html',value) + return attr+'="'+value+'"' +html=re.sub(r'\b(src|href)="([^"]*)"',absolute,html) +(target/'index.html').write_text(html) +layout=app/'lib/frontend/themes/basic/layouts/main.tpl' +original=subprocess.check_output(['runuser','-u','dunerealms','--','git','-C',str(app),'show','HEAD:lib/frontend/themes/basic/layouts/main.tpl'],text=True) +layout.write_text(original.replace('','\n')) +sql="""UPDATE dunerealms_oscommerce.platforms SET is_default=0,status=0 WHERE platform_id IN (1,7,8,9,10); +UPDATE dunerealms_oscommerce.platforms SET is_default=1,status=1,platform_name='DuneRealms Shop',platform_owner='DuneRealms',platform_url='shop.dunerealms.com/catalog',platform_url_secure='shop.dunerealms.com/catalog',ssl_enabled=2 WHERE platform_id=7; +UPDATE dunerealms_oscommerce.configuration SET configuration_value='DuneRealms Shop' WHERE configuration_key='STORE_NAME'; +UPDATE dunerealms_oscommerce.products SET products_status=0; +""" +subprocess.run(['mysql'],input=sql,text=True,check=True,capture_output=True) +subprocess.run(['chown','dunerealms:dunerealms',str(layout)],check=True) +print('Published independent portal with central header/footer and osCommerce iframe; original shop page unchanged') diff --git a/website/ops/oscommerce/setup-osc-account.py b/website/ops/oscommerce/setup-osc-account.py new file mode 100644 index 00000000..da2f5ea1 --- /dev/null +++ b/website/ops/oscommerce/setup-osc-account.py @@ -0,0 +1,14 @@ +from pathlib import Path +import subprocess +app=Path('/home/dunerealms/apps/oscommerce') +sql="""CREATE TABLE IF NOT EXISTS dunerealms_oscommerce.dune_account_links(account_id CHAR(36) PRIMARY KEY,customer_id INT NOT NULL UNIQUE); +CREATE TABLE IF NOT EXISTS dunerealms_oscommerce.dune_sso_states(state_hash CHAR(64) PRIMARY KEY,nonce_hash CHAR(64) NOT NULL,next_path VARCHAR(2048) NOT NULL,expires_at BIGINT NOT NULL); +CREATE TABLE IF NOT EXISTS dunerealms_oscommerce.dune_sso_sessions(token_hash CHAR(64) PRIMARY KEY,account_id CHAR(36) NOT NULL,session_ref CHAR(64) NOT NULL,expires_at BIGINT NOT NULL); +""" +subprocess.run(['mysql'],input=sql,text=True,capture_output=True,check=True) +entry=app/'lib/frontend/web/index.php';s=entry.read_text() +if 'DuneAccount' not in s:s=s.replace('$application->run();',"require __DIR__.'/../components/DuneAccount.php';\n(new \\frontend\\components\\DuneAccount())->bootstrap($application);\n$application->run();") +entry.write_text(s) +(app/'dune-login.php').write_text("{ + const db=database({id:'11111111-1111-4111-8111-111111111111',username:'tester',role:'user'}); + const state='s'.repeat(43),token='t'.repeat(43); + const response=await createIntegrationSSO(db)(new Request('https://cp.dunerealms.com/sso/authorize?client=oscommerce&state='+state+'&redirect_uri=https://attacker.invalid/',{headers:{cookie:'__Host-dune_session='+token}})); + assert.equal(response.status,302); + const callback=new URL(response.headers.get('location')); + assert.equal(callback.origin,'https://shop.dunerealms.com'); + assert.equal(callback.pathname,'/dune-login.php');assert.equal(callback.searchParams.get('state'),state); + const code=callback.searchParams.get('code');assert.match(code,/^[A-Za-z0-9_-]{43}$/); + const issue=db.writes.find(row=>row.sql.startsWith('INSERT INTO integration_sso_codes')); + assert.equal(issue.values[0],createHash('sha256').update(code).digest('hex')); + assert.equal(issue.values[3],'oscommerce');assert.ok(issue.values[4]>Date.now()&&issue.values[4]<=Date.now()+60000); + assert.equal(response.headers.get('referrer-policy'),'no-referrer'); +}); +test('adding osCommerce preserves the existing Azuriom callback',async()=>{ + const response=await createIntegrationSSO(database({id:'test',username:'tester',role:'user'}))(new Request('https://cp.dunerealms.com/sso/authorize?client=shop&state='+'a'.repeat(43),{headers:{cookie:'__Host-dune_session='+'t'.repeat(43)}})); + assert.equal(new URL(response.headers.get('location')).pathname,'/store/dune-login'); +}); +test('invalid states, unknown clients, unauthenticated redemption and expired codes are rejected',async()=>{ + const handler=createIntegrationSSO(database(),{INTEGRATION_SSO_SECRET:'x'.repeat(40)}); + for(const query of ['client=oscommerce&state=short','client=unknown&state='+'a'.repeat(43)])assert.equal((await handler(new Request('https://cp.dunerealms.com/sso/authorize?'+query))).status,400); + const request=(auth)=>new Request('https://cp.dunerealms.com/internal/integrations/redeem',{method:'POST',headers:{'content-type':'application/json',authorization:auth},body:JSON.stringify({client:'oscommerce',code:'c'.repeat(43)})}); + assert.equal((await handler(request('Bearer wrong'))).status,401); + assert.equal((await handler(request('Bearer '+'x'.repeat(40)))).status,401); +}); diff --git a/website/web/oscommerce-embed.js b/website/web/oscommerce-embed.js new file mode 100644 index 00000000..d1e85b8f --- /dev/null +++ b/website/web/oscommerce-embed.js @@ -0,0 +1 @@ +(()=>{const frame=document.querySelector('.dune-store-frame iframe');if(!frame)return;const origin='https://shop.dunerealms.com';frame.addEventListener('load',()=>frame.contentWindow?.postMessage({type:'dune-shop-measure'},origin));window.addEventListener('message',event=>{if(event.origin!==origin||event.source!==frame.contentWindow)return;const data=event.data;if(data?.type==='dune-shop-size'&&Number.isFinite(data.height)&&data.height>=100&&data.height<100000){frame.style.height=Math.max(600,Math.ceil(data.height))+'px';frame.setAttribute('scrolling','no');}if(data?.type==='dune-shop-signin'){try{const target=new URL(data.url);if(target.origin==='https://cp.dunerealms.com'&&target.pathname==='/sso/authorize'&&target.searchParams.get('client')==='oscommerce')location.assign(target.href);}catch{}}});})(); diff --git a/website/web/oscommerce-inner.js b/website/web/oscommerce-inner.js new file mode 100644 index 00000000..d1745a97 --- /dev/null +++ b/website/web/oscommerce-inner.js @@ -0,0 +1 @@ +(()=>{if(window.parent===window)return;const allowed=new Set(['https://shop.dunerealms.com','https://www.dunerealms.com','https://dunerealms.com','https://cp.dunerealms.com']);let origin;try{origin=new URL(document.referrer).origin;}catch{}if(!allowed.has(origin))return;const send=()=>parent.postMessage({type:'dune-shop-size',height:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)},origin);window.addEventListener('message',e=>{if(e.origin===origin&&e.source===parent&&e.data?.type==='dune-shop-measure')send();});window.addEventListener('load',send);new ResizeObserver(send).observe(document.body);})(); diff --git a/website/web/portal-navigation.js b/website/web/portal-navigation.js index a64a9f9c..50e7b65d 100644 --- a/website/web/portal-navigation.js +++ b/website/web/portal-navigation.js @@ -1,5 +1,5 @@ (()=>{let menuIndex=0;for(const header of document.querySelectorAll('.dune-site-header')){if(window.top!==window.self){header.hidden=true;continue;}const toggle=header.querySelector('.menu-toggle'),nav=header.querySelector('nav');if(!toggle||!nav)continue;if(!nav.id){do{nav.id='dune-main-navigation-'+(++menuIndex);}while(document.getElementById(nav.id)!==nav);}toggle.setAttribute('aria-controls',nav.id);const setOpen=open=>{nav.classList.toggle('open',open);toggle.setAttribute('aria-expanded',String(open));toggle.setAttribute('aria-label',open?'Close navigation':'Open navigation');};setOpen(nav.classList.contains('open'));toggle.addEventListener('click',event=>{event.stopImmediatePropagation();setOpen(!nav.classList.contains('open'));},true);header.addEventListener('keydown',event=>{if(event.key==='Escape'&&nav.classList.contains('open')){event.preventDefault();setOpen(false);toggle.focus();}});for(const a of nav.querySelectorAll('a')){const url=new URL(a.href);if(url.host===location.host&&url.pathname===location.pathname&&url.hash===location.hash)a.setAttribute('aria-current','page');}}})();(()=>{if(window.top!==window.self){document.documentElement.classList.add('dune-embedded');return;}const links=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kit Exchange","https://www.dunerealms.com/kits.html","items/office_water.png"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Manual/wiki","https://wiki.dunerealms.com/","nav-manual-v2.webp"],["Staff roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Support center","https://support.dunerealms.com/","nav-support-v2.webp"],["Account center","https://cp.dunerealms.com/","nav-account-v2.webp"],["Clan center","https://clans.dunerealms.com/","nav-clan-v2.webp"]],choose=function pageContextFor(value,links=PORTAL_LINKS){ - const url=new URL(value),host=url.hostname;if(host==='corp.dunerealms.com')return {label:'Company CP',icon:'clans/vaerkring-v1.png'};if(url.pathname==='/dunemark-collection.html')return {label:'Dunemark Collection',icon:'imperial-postbank-v2.png'};if(url.pathname==='/government.html')return {label:'Realm & Politics',icon:'seals/office-landsraad.png'};if(url.pathname==='/kits.html')return {label:'Kit Exchange',icon:'items/office_water.png'};if(url.pathname==='/shop.html')return {label:'Shop',icon:'nav-exchange-v2.webp'}; if(host==='wiki.dunerealms.com')return {label:'Manual/wiki',icon:'nav-manual-full-v2.webp'}; + const url=new URL(value),host=url.hostname;if(host==='shop.dunerealms.com')return {label:'Shop',icon:'nav-shop-v1.webp'};if(host==='corp.dunerealms.com')return {label:'Company CP',icon:'clans/vaerkring-v1.png'};if(url.pathname==='/dunemark-collection.html')return {label:'Dunemark Collection',icon:'imperial-postbank-v2.png'};if(url.pathname==='/government.html')return {label:'Realm & Politics',icon:'seals/office-landsraad.png'};if(url.pathname==='/kits.html')return {label:'Kit Exchange',icon:'items/office_water.png'};if(url.pathname==='/shop.html')return {label:'Shop',icon:'nav-exchange-v2.webp'}; if(host==='wiki.dunerealms.com')return {label:'Manual/wiki',icon:'nav-manual-full-v2.webp'}; if(url.pathname.startsWith('/news/'))return {label:'News dispatch',icon:'nav-discord-full-v2.webp'}; if(url.pathname==='/news-archive.html')return {label:url.searchParams.has('post')?'News dispatch':'News archive',icon:'nav-discord-full-v2.webp'}; if(host==='cp.dunerealms.com'){const pages={'#website-posts':['Website posts','discord'],'#permissions':['Website ranks','account'],'#staff-manual':['Staff manual','manual'],'#server-operations':['Server operations','home'],'#staff-tickets':['Staff ticket desk','support'],'#forum-admin':['Forum moderation','boards'],'#exchange-admin':['Exchange administration','exchange'],'#staff':['Administration','account']};const page=pages[url.hash];if(page)return {label:page[0],icon:'nav-'+page[1]+'-full-v2.webp'};} @@ -31,13 +31,13 @@ (()=>{const stamp=()=>{const brand=document.querySelector('.dune-site-header .wordmark');if(!brand)return false;if(!brand.querySelector('.dune-release-badge')){const badge=document.createElement('span');badge.className='dune-release-badge';badge.textContent='Alpha';brand.append(badge);fetch('/release.json',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(release=>{if(release&&release.stage==='alpha'&&/^\d+(?:\.\d+){3}$/.test(release.version))badge.textContent='Alpha '+release.version;}).catch(()=>{});}return true;};if(!stamp()){const observer=new MutationObserver(()=>{if(stamp())observer.disconnect();});observer.observe(document.documentElement,{childList:true,subtree:true});}})(); /* Unified main menu Shop v1 */ -(()=>{const update=()=>{for(const nav of document.querySelectorAll('header nav[aria-label="Main navigation"]')){if(nav.querySelector('a[data-dune-shop],a[href="https://www.dunerealms.com/shop.html"]'))continue;const a=document.createElement('a');a.href='https://www.dunerealms.com/shop.html';a.dataset.duneShop='1';const i=document.createElement('img');i.src='https://www.dunerealms.com/assets/nav-exchange-v2.webp';i.alt='';i.width=34;i.height=34;const t=document.createElement('span');t.textContent='Shop';a.append(i,t);const exchange=[...nav.querySelectorAll('a')].find(a=>a.textContent.trim()==='Exchange'||a.textContent.trim()==='Exchange');if(exchange)exchange.after(a);else nav.append(a);}};update();new MutationObserver(update).observe(document.body,{childList:true,subtree:true});})(); +(()=>{const update=()=>{for(const nav of document.querySelectorAll('header nav[aria-label="Main navigation"]')){if(nav.querySelector('a[data-dune-shop],a[href="https://shop.dunerealms.com/"]'))continue;const a=document.createElement('a');a.href='https://shop.dunerealms.com/';a.dataset.duneShop='1';const i=document.createElement('img');i.src='https://www.dunerealms.com/assets/nav-exchange-v2.webp';i.alt='';i.width=34;i.height=34;const t=document.createElement('span');t.textContent='Shop';a.append(i,t);const exchange=[...nav.querySelectorAll('a')].find(a=>a.textContent.trim()==='Exchange'||a.textContent.trim()==='Exchange');if(exchange)exchange.after(a);else nav.append(a);}};update();new MutationObserver(update).observe(document.body,{childList:true,subtree:true});})(); /* Main menu order v2 */ /* Shop SALES indicator v1: inactive until a real promotion is active */ -(()=>{let active=new URLSearchParams(location.search).get('sale-preview')==='1';if(active)document.body.classList.add('dune-sale-preview');const draw=()=>{for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a[href="https://www.dunerealms.com/shop.html"]')){let badge=a.querySelector('.dune-sales-overlay');if(active&&!badge){badge=document.createElement('span');badge.className='dune-sales-overlay';badge.textContent='SALE';badge.setAttribute('aria-label','Shop sale active');a.append(badge);}else if(!active&&badge)badge.remove();a.classList.toggle('dune-shop-sale-active',active);}};window.addEventListener('dune:shop-promotions',e=>{active=e.detail?.active===true;draw();});draw();new MutationObserver(draw).observe(document.body,{childList:true,subtree:true});})(); +(()=>{let active=new URLSearchParams(location.search).get('sale-preview')==='1';if(active)document.body.classList.add('dune-sale-preview');const draw=()=>{for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a[href="https://shop.dunerealms.com/"]')){let badge=a.querySelector('.dune-sales-overlay');if(active&&!badge){badge=document.createElement('span');badge.className='dune-sales-overlay';badge.textContent='SALE';badge.setAttribute('aria-label','Shop sale active');a.append(badge);}else if(!active&&badge)badge.remove();a.classList.toggle('dune-shop-sale-active',active);}};window.addEventListener('dune:shop-promotions',e=>{active=e.detail?.active===true;draw();});draw();new MutationObserver(draw).observe(document.body,{childList:true,subtree:true});})(); /* Sir Patrick Stewart header memorial */ (()=>{const place=()=>{const header=document.querySelector('header.dune-site-header')||document.querySelector('body>header');if(!header||header.querySelector('.dune-memorial'))return;const tribute=document.createElement('aside');tribute.className='dune-memorial';tribute.setAttribute('aria-label','In memory of Sir Patrick Stewart');tribute.title='In memory of Sir Patrick Stewart';const portrait=document.createElement('img');portrait.src='https://www.dunerealms.com/assets/sir-patrick-stewart-memorial-v1.webp';portrait.alt='Sir Patrick Stewart, remembered within a heraldic shield with a black mourning ribbon';portrait.width=96;portrait.height=96;const text=document.createElement('span');text.textContent='In memory of';const name=document.createElement('strong');name.textContent='Sir Patrick Stewart';tribute.append(portrait,text,name);header.append(tribute);};place();new MutationObserver(place).observe(document.body,{childList:true,subtree:true});})(); @@ -49,7 +49,7 @@ (()=>{function link(){const foot=document.querySelector('.dune-shared-footer');if(!foot)return;const nav=foot.querySelector('nav');if(!nav)return;let a=nav.querySelector('[data-dune-git-footer]');if(!a){a=document.createElement('a');a.dataset.duneGitFooter='1';nav.append(a);}a.href='https://www.dunerealms.com/git/unimatrix/MC';a.textContent='DuneGit';}link();new MutationObserver(link).observe(document.body,{childList:true});addEventListener('hashchange',link);})(); /* Dune canonical menu begin */ -(()=>{if(window.top!==window.self)return;const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://www.dunerealms.com/shop.html","nav-exchange-full-v2.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Staff roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kit Exchange","https://www.dunerealms.com/kits.html","items/office_water.png"],["Support center","https://support.dunerealms.com/","nav-support-v2.webp"],["Account center","https://cp.dunerealms.com/","nav-account-v2.webp"],["Clan center","https://clans.dunerealms.com/","nav-clan-v2.webp"],["Dunopedia","https://wiki.dunerealms.com/","nav-manual-v2.webp"]];const canonicalMenuHref=function canonicalMenuHref(value){const u=new URL(value,'https://www.dunerealms.com');if(u.hostname==='dunerealms.com')u.hostname='www.dunerealms.com';if(u.hostname==='www.dunerealms.com'&&/^\/(manual|wiki)\.html$/.test(u.pathname))return'https://wiki.dunerealms.com/';if(u.hostname==='cp.dunerealms.com'&&u.pathname==='/'){if(u.hash==='#shop')return'https://www.dunerealms.com/shop.html';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';return u.origin+(u.pathname==='/index.html'?'/':u.pathname);};const normalizeMainMenus=function normalizeMainMenus(doc,currentUrl,links=MAIN_MENU){let changes=0;const set=(node,key,value)=>{if(node.getAttribute(key)!==value){node.setAttribute(key,value);changes++;}}; +(()=>{if(window.top!==window.self)return;const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://shop.dunerealms.com/","nav-shop-v1.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Staff roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kit Exchange","https://www.dunerealms.com/kits.html","items/office_water.png"],["Support center","https://support.dunerealms.com/","nav-support-v2.webp"],["Account center","https://cp.dunerealms.com/","nav-account-v2.webp"],["Clan center","https://clans.dunerealms.com/","nav-clan-v2.webp"],["Dunopedia","https://wiki.dunerealms.com/","nav-manual-v2.webp"]];const canonicalMenuHref=function canonicalMenuHref(value){const u=new URL(value,'https://www.dunerealms.com');if(u.hostname==='dunerealms.com')u.hostname='www.dunerealms.com';if(u.hostname==='www.dunerealms.com'&&/^\/(manual|wiki)\.html$/.test(u.pathname))return'https://wiki.dunerealms.com/';if(u.hostname==='cp.dunerealms.com'&&u.pathname==='/'){if(u.hash==='#shop')return'https://shop.dunerealms.com/';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';return u.origin+(u.pathname==='/index.html'?'/':u.pathname);};const normalizeMainMenus=function normalizeMainMenus(doc,currentUrl,links=MAIN_MENU){let changes=0;const set=(node,key,value)=>{if(node.getAttribute(key)!==value){node.setAttribute(key,value);changes++;}}; for(const nav of doc.querySelectorAll('header nav[aria-label="Main navigation"]')){const old=[...nav.querySelectorAll('a')],ordered=[];for(const[name,href,icon]of links){let a=old.find(x=>!ordered.includes(x)&&canonicalMenuHref(x.href)===href);if(!a){a=doc.createElement('a');changes++;}set(a,'href',href);let image=a.querySelector('img');if(!image){image=doc.createElement('img');a.insertBefore(image,a.firstChild);changes++;}set(image,'src','https://www.dunerealms.com/assets/'+icon);set(image,'alt','');set(image,'width','34');set(image,'height','34');let label=[...a.children].find(x=>x.tagName==='SPAN'&&!x.classList.contains('dune-new-overlay')&&!x.classList.contains('dune-sales-overlay'));if(!label){label=doc.createElement('span');a.append(label);changes++;}set(label,'data-dune-nav-label','1');if(label.textContent!==name){label.textContent=name;changes++;}for(const n of [...a.childNodes])if(n.nodeType===3){n.remove();changes++;}const active=canonicalMenuHref(currentUrl)===href;if(active)set(a,'aria-current','page');else if(a.hasAttribute('aria-current')){a.removeAttribute('aria-current');changes++;}ordered.push(a);} for(const a of old)if(!ordered.includes(a)){a.remove();changes++;}let cursor=nav.firstElementChild;for(const a of ordered){if(a!==cursor){nav.insertBefore(a,cursor);changes++;}cursor=a.nextElementSibling;}} return changes; @@ -62,7 +62,7 @@ (()=>{function sync(){const nav=document.querySelector('.dune-shared-footer nav');if(!nav||nav.querySelector('[data-bank-rates]'))return;const a=document.createElement('a');a.dataset.bankRates='1';a.href='https://www.dunerealms.com/rates-and-charges.html';a.textContent='Rates & Charges';nav.append(a);}sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});})(); /* Central automatic release menu badges */ -(()=>{let items=[{"href":"https://cp.dunerealms.com/#shop","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://wiki.dunerealms.com/","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://clans.dunerealms.com/","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://cp.dunerealms.com/","badge":"NEW","updatedIn":"1.0.1.0","introducedIn":"1.0.1.0"},{"href":"https://cp.dunerealms.com/#exchange","updatedIn":"1.0.0.2","badge":"UPDATE"},{"href":"https://support.dunerealms.com/","updatedIn":"1.0.0.3","badge":"UPDATE"},{"href":"https://www.dunerealms.com/staff.html","updatedIn":"1.0.0.5","badge":"UPDATE"},{"href":"https://www.dunerealms.com/","badge":"NEW","introducedIn":"1.0.0.3","updatedIn":"1.0.0.3"},{"href":"https://www.dunerealms.com/shop.html","updatedIn":"1.0.0.5","badge":"UPDATE"},{"href":"https://www.dunerealms.com/kits.html","introducedIn":"1.0.0.5","badge":"NEW"},{"href":"https://cp.dunerealms.com/#kits-exchange","introducedIn":"1.0.0.5","badge":"NEW"},{"href":"https://cp.dunerealms.com/#realm","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#bureau","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#forge","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#politics","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#post","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#bank","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#market","badge":"NEW","introducedIn":"v2-api"},{"href":"https://www.dunerealms.com/rates-and-charges.html","updatedIn":"1.0.1.0","badge":"UPDATE"}];function mark(){const release=document.querySelector('.dune-release-badge')?.textContent.match(/\d+(?:\.\d+){3}/)?.[0];for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a,#portals .portal[data-id]')){const href=a.matches('#portals .portal')?(document.body.dataset.cpMode==='clan'?'https://clans.dunerealms.com/#':'https://cp.dunerealms.com/#')+a.dataset.id:a.href;const item=items.find(x=>x.href===href),label=['NEW','UPDATE'].includes(item?.badge)?item.badge:null;let tag=a.querySelector('.dune-new-overlay');if(label){if(!tag){tag=document.createElement('span');tag.className='dune-new-overlay';a.append(tag);}if(tag.textContent!==label)tag.textContent=label;tag.classList.toggle('dune-update-overlay',label==='UPDATE');tag.setAttribute('aria-label',label==='NEW'?'New this release':'Updated this release');}else if(tag)tag.remove();}}fetch('https://cp.dunerealms.com/api/menu-badges',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(Array.isArray(data?.items)){items=data.items;mark();}}).catch(()=>{});mark();new MutationObserver(mark).observe(document.body,{childList:true,subtree:true,characterData:true});})(); +(()=>{let items=[{"href":"https://cp.dunerealms.com/#shop","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://wiki.dunerealms.com/","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://clans.dunerealms.com/","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://cp.dunerealms.com/","badge":"NEW","updatedIn":"1.0.1.0","introducedIn":"1.0.1.0"},{"href":"https://cp.dunerealms.com/#exchange","updatedIn":"1.0.0.2","badge":"UPDATE"},{"href":"https://support.dunerealms.com/","updatedIn":"1.0.0.3","badge":"UPDATE"},{"href":"https://www.dunerealms.com/staff.html","updatedIn":"1.0.0.5","badge":"UPDATE"},{"href":"https://www.dunerealms.com/","badge":"NEW","introducedIn":"1.0.0.3","updatedIn":"1.0.0.3"},{"href":"https://shop.dunerealms.com/","updatedIn":"1.0.0.5","badge":"UPDATE"},{"href":"https://www.dunerealms.com/kits.html","introducedIn":"1.0.0.5","badge":"NEW"},{"href":"https://cp.dunerealms.com/#kits-exchange","introducedIn":"1.0.0.5","badge":"NEW"},{"href":"https://cp.dunerealms.com/#realm","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#bureau","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#forge","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#politics","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#post","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#bank","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#market","badge":"NEW","introducedIn":"v2-api"},{"href":"https://www.dunerealms.com/rates-and-charges.html","updatedIn":"1.0.1.0","badge":"UPDATE"}];function mark(){const release=document.querySelector('.dune-release-badge')?.textContent.match(/\d+(?:\.\d+){3}/)?.[0];for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a,#portals .portal[data-id]')){const href=a.matches('#portals .portal')?(document.body.dataset.cpMode==='clan'?'https://clans.dunerealms.com/#':'https://cp.dunerealms.com/#')+a.dataset.id:a.href;const item=items.find(x=>x.href===href),label=['NEW','UPDATE'].includes(item?.badge)?item.badge:null;let tag=a.querySelector('.dune-new-overlay');if(label){if(!tag){tag=document.createElement('span');tag.className='dune-new-overlay';a.append(tag);}if(tag.textContent!==label)tag.textContent=label;tag.classList.toggle('dune-update-overlay',label==='UPDATE');tag.setAttribute('aria-label',label==='NEW'?'New this release':'Updated this release');}else if(tag)tag.remove();}}fetch('https://cp.dunerealms.com/api/menu-badges',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(Array.isArray(data?.items)){items=data.items;mark();}}).catch(()=>{});mark();new MutationObserver(mark).observe(document.body,{childList:true,subtree:true,characterData:true});})(); /* Shared contextual page banner */ (()=>{if(window.top!==window.self)return;const titles={'dunemark-collection.html':['IMPERIAL POSTBANK','The Dunemark Collection'],'staff.html':['STAFF & ORGANISATION','The people behind the realms'],'government.html':['REALM & POLITICS','Government, Houses and elected offices'],'rates-and-charges.html':['IMPERIAL POSTBANK','Rates & Charges'],'shop.html':['DUNEFORGE SHOP','Goods and services for your journey'],'kits.html':['KIT EXCHANGE','Equip your next adventure'],'exchange.html':['CHOAM EXCHANGE','Trade across the realms'],'discord.html':['COMMUNITY DISCORD','The caravan frequency'],'news.html':['NEWS FROM THE REALM','The Imperial Dispatch'],'news-archive.html':['NEWS ARCHIVE','Dispatches from across the realms']}; diff --git a/website/web/shop-oscommerce.html b/website/web/shop-oscommerce.html new file mode 100644 index 00000000..6246161c --- /dev/null +++ b/website/web/shop-oscommerce.html @@ -0,0 +1 @@ +Shop · DuneRealms

Prices are in euro. Available payment methods are shown at checkout. Looking for player-designed kits? Visit the Kit Exchange.

\ No newline at end of file From fdb5d04cdd278813ea21f68e76fd648e215d941d Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 16 Nov 2026 16:25:37 +0000 Subject: [PATCH 3/3] Polish shop portal styling and account callback setup --- website/ops/oscommerce/dune-oscommerce.css | 1 + website/ops/oscommerce/setup-osc-account.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/website/ops/oscommerce/dune-oscommerce.css b/website/ops/oscommerce/dune-oscommerce.css index ea99a8ff..988745c1 100644 --- a/website/ops/oscommerce/dune-oscommerce.css +++ b/website/ops/oscommerce/dune-oscommerce.css @@ -8,4 +8,5 @@ body{margin:0!important}.main-content{background:transparent!important;min-heigh .dune-shop-toolbar{max-width:1340px;margin:16px auto;display:flex;gap:12px;justify-content:flex-end;flex-wrap:wrap}.dune-shop-toolbar a,.dune-shop-link{border:1px solid var(--dune-line);border-radius:8px;background:#193a2d;color:var(--dune-gold)!important;padding:10px 16px;text-decoration:none;font-weight:600} .main-content a{color:var(--dune-gold)}.main-content h1,.main-content h2,.main-content h3,.main-content h4{color:var(--dune-gold)!important}.main-content .item,.main-content .product-item,.main-content .product-listing-item,.main-content .w-block{background:var(--dune-panel)!important;border-color:#456247!important;border-radius:12px}.main-content input,.main-content select,.main-content textarea{background:#0b241c!important;color:#eee6d3!important;border:1px solid #63734e!important;border-radius:6px}.main-content .btn,.main-content button,.main-content input[type=submit]{background:linear-gradient(#254b35,#173829)!important;color:var(--dune-gold)!important;border:1px solid var(--dune-line)!important;border-radius:8px!important;box-shadow:0 3px 8px #0003}.main-content .btn:hover,.main-content button:hover{filter:brightness(1.15)} .dune-shop-footer{margin-top:32px;padding:30px 4vw;border-top:1px solid #63734e;background:#091c16;text-align:center;color:#b8cbb6;font-size:13px}.dune-shop-footer a{color:var(--dune-gold);margin:0 10px}.dune-shop-footer p{margin:12px 0 0;font-size:12px}.dune-shop-footer strong{color:var(--dune-gold);font-size:17px}.dune-shop-powered{opacity:.65;font-size:11px!important} +.block.header,.header-middle,.header-menu-holder,.header-menu,.w-block-box,.w-breadcrumb,.footer{background:#143328!important;color:var(--dune-text)!important}.block.header{border:1px solid var(--dune-line);border-radius:12px;padding:12px}.header .w-logo,.w-header-stock{display:none!important}.header a,.header-menu a,.footer a{color:var(--dune-gold)!important}.header-middle{border-top:1px solid #496344;border-bottom:1px solid #496344;padding:14px 0!important}.main-content{border:1px solid #496344;border-radius:12px;padding:24px!important;margin:18px auto!important}.w-block-box input,.w-block-box select{background:#0b241c!important;color:var(--dune-text)!important;border-color:#657649!important}.btn-1,.btn-2,.btn-3,.button-search,.btn-primary{background:linear-gradient(#31563a,#18392a)!important;border:1px solid var(--dune-line)!important;color:var(--dune-gold)!important;border-radius:8px!important}.footer{margin-top:16px;border-top:1px solid #496344;padding:16px}.footer .w-logo{display:none!important}.w-breadcrumb a,.breadcrumb a{color:#b8cbb6!important} @media(max-width:700px){.dune-shop-hero{margin:16px 12px 0;padding:20px;gap:16px}.dune-shop-hero img{width:70px;height:70px}.dune-shop-hero h1{font-size:28px}.dune-shop-toolbar{margin:16px 12px;justify-content:center}.main-content{padding:18px 12px!important}.dune-shop-header nav a{padding:7px;font-size:11px}.dune-shop-header nav img{width:26px;height:26px}} diff --git a/website/ops/oscommerce/setup-osc-account.py b/website/ops/oscommerce/setup-osc-account.py index da2f5ea1..7a368f0b 100644 --- a/website/ops/oscommerce/setup-osc-account.py +++ b/website/ops/oscommerce/setup-osc-account.py @@ -10,5 +10,9 @@ entry=app/'lib/frontend/web/index.php';s=entry.read_text() if 'DuneAccount' not in s:s=s.replace('$application->run();',"require __DIR__.'/../components/DuneAccount.php';\n(new \\frontend\\components\\DuneAccount())->bootstrap($application);\n$application->run();") entry.write_text(s) (app/'dune-login.php').write_text("