镜像自地址
https://github.com/JGZYES/ParlzPackageManger.git
已同步 2026-09-11 08:52:45 +08:00
Client src/pmu.c (independent binary, links out.c + sha256.c): - pmu register <email> <pwd>: local arithmetic human-verification, then POST register.php. - pmu login / logout / whoami: session token stored in ~/.pmu/config. - pmu ./x.pdm (or 'pmu publish x.pdm'): parses Package/Version/Architecture from the .pdm, computes sha256, uploads raw bytes with a Bearer token; the server auto-generates <pkg>.json and stores the .pdm; duplicate names are rejected. Server web/pmu/*.php: - lib.php: JSON responses, token auth, data store in web/pmu/data/*.json (gitignored). - register/login/logout/publish.php: account + session + upload + registry write (writes web/mirror/packages/<name>.json, copies .pdm, appends packages.json). - Duplicate package names -> 409; missing/invalid token -> 401. Also: .gitignore web/pmu/data/*.json; release.yml builds pmu per-platform.
19 行
756 B
PHP
19 行
756 B
PHP
<?php
|
|
/* web/pmu/register.php — create an account. Human verification is done client-side:
|
|
* the pmu client asks a local arithmetic question before calling here. */
|
|
define('PMM_SITE', 1);
|
|
require __DIR__ . '/lib.php';
|
|
|
|
$d = pmu_read_json();
|
|
$email = trim((string)($d['email'] ?? ''));
|
|
$pass = (string)($d['password'] ?? '');
|
|
if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) pmu_fail('invalid email');
|
|
if (strlen($pass) < 6) pmu_fail('password too short (>= 6 chars)');
|
|
|
|
$users = pmu_load('users.json');
|
|
if (isset($users[$email])) pmu_fail('email already registered', 409);
|
|
|
|
$users[$email] = ['email' => $email, 'hash' => password_hash($pass, PASSWORD_DEFAULT), 'created' => time()];
|
|
pmu_save('users.json', $users);
|
|
pmu_ok(['email' => $email]);
|