mirror of
https://github.com/myronblair/novacpx
synced 2026-07-28 05:03:14 -05:00
Add full API endpoint suite, lib managers, webmail (Roundcube :8883), and NovaCPX icon/branding assets
- 14 API endpoints: accounts, packages, domains, dns, email, databases, ftp, ssl, cron, php, files, stats, webmail, server_setup - 8 lib managers: AccountManager, VhostManager, DNSManager, EmailManager, DatabaseManager, PHPManager, FTPManager, SSLManager - Roundcube webmail on dedicated port 8883 (sequenced after 8880/8881/8882) - Custom NovaCPX SVG icon sprite (30+ unique icons), logo, mark, favicon - PORT_WEBMAIL=8883 wired into Core.php, install.sh, UFW, Fail2Ban, credentials file Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
$db = DB::getInstance();
|
||||
$body = json_decode(file_get_contents('php://input'), true) ?? [];
|
||||
require_once NOVACPX_LIB . '/FTPManager.php';
|
||||
|
||||
$user = Auth::getInstance()->user();
|
||||
$accountId = $user['role'] === 'user'
|
||||
? (int)($db->fetchOne("SELECT id FROM accounts WHERE user_id = ?", [$user['uid']])['id'] ?? 0)
|
||||
: (int)($body['account_id'] ?? $_GET['account_id'] ?? 0);
|
||||
|
||||
match ($action) {
|
||||
'list' => (function() use ($db, $accountId) {
|
||||
Response::success($db->fetchAll("SELECT id, username, home_dir, quota_mb, status, created_at FROM ftp_accounts WHERE account_id = ?", [$accountId]));
|
||||
})(),
|
||||
|
||||
'create' => (function() use ($db, $body, $accountId) {
|
||||
if (!$accountId) Response::error("account_id required");
|
||||
$username = trim($body['username'] ?? '');
|
||||
$password = $body['password'] ?? bin2hex(random_bytes(6));
|
||||
$acct = $db->fetchOne("SELECT home_dir FROM accounts WHERE id = ?", [$accountId]);
|
||||
$homeDir = $body['home_dir'] ?? ($acct['home_dir'] . '/public_html');
|
||||
if (!$username) Response::error("username required");
|
||||
$id = FTPManager::createAccount($accountId, $username, $password, $homeDir, (int)($body['quota_mb'] ?? 0));
|
||||
audit('ftp.create', $username);
|
||||
Response::success(['id' => $id, 'password' => $password], 'FTP account created');
|
||||
})(),
|
||||
|
||||
'delete' => (function() use ($body) {
|
||||
FTPManager::deleteAccount((int)($body['id'] ?? 0));
|
||||
audit('ftp.delete', "ftp:{$body['id']}");
|
||||
Response::success(null, 'FTP account deleted');
|
||||
})(),
|
||||
|
||||
'change-password' => (function() use ($body) {
|
||||
FTPManager::changePassword((int)($body['id'] ?? 0), $body['password'] ?? '');
|
||||
Response::success(null, 'FTP password updated');
|
||||
})(),
|
||||
|
||||
default => Response::error("Unknown ftp action: $action", 404),
|
||||
};
|
||||
Reference in New Issue
Block a user