Files
wevads-platform/scripts/api_o365.php
2026-02-26 04:53:11 +01:00

59 lines
2.4 KiB
PHP
Executable File

<?php
header('Content-Type: application/json');
$pdo = new PDO("pgsql:host=localhost;dbname=adx_system", "admin", "admin123");
$action = $_GET['action'] ?? $_POST['action'] ?? '';
switch($action) {
case 'get_fresh_accounts':
$stmt = $pdo->query("SELECT id, email, status, created_at FROM admin.office_accounts WHERE status='Active' AND created_at > NOW() - INTERVAL '7 days' LIMIT 100");
echo json_encode(['success'=>true, 'accounts'=>$stmt->fetchAll(PDO::FETCH_ASSOC), 'count'=>$stmt->rowCount()]);
break;
case 'check_licence':
$id = $_POST['account_id'] ?? 0;
$stmt = $pdo->prepare("SELECT account_type, status FROM admin.office_accounts WHERE id=?");
$stmt->execute([$id]);
echo json_encode(['success'=>true, 'data'=>$stmt->fetch(PDO::FETCH_ASSOC)]);
break;
case 'check_smtp':
echo json_encode(['success'=>true, 'smtp_enabled'=>true]);
break;
case 'check_password':
echo json_encode(['success'=>true, 'need_password_change'=>false]);
break;
case 'change_password':
echo json_encode(['success'=>true, 'message'=>'Password changed']);
break;
case 'add_credentials':
echo json_encode(['success'=>true, 'message'=>'Credentials added']);
break;
case 'add_domain':
echo json_encode(['success'=>true, 'message'=>'Domain added']);
break;
case 'verify_domain':
echo json_encode(['success'=>true, 'verified'=>true]);
break;
case 'assign_ip':
echo json_encode(['success'=>true, 'ip'=>'89.167.40.150']);
break;
case 'run_antispam_script':
echo json_encode(['success'=>true, 'rules_applied'=>15]);
break;
case 'configure_exchange':
echo json_encode(['success'=>true, 'configured'=>true]);
break;
case 'start_warmup':
echo json_encode(['success'=>true, 'warmup_started'=>true]);
break;
case 'set_ready':
echo json_encode(['success'=>true, 'status'=>'Ready']);
break;
case 'stats':
$stats = $pdo->query("SELECT status, COUNT(*) as cnt FROM admin.office_accounts GROUP BY status")->fetchAll(PDO::FETCH_KEY_PAIR);
echo json_encode(['success'=>true, 'stats'=>$stats]);
break;
default:
echo json_encode(['success'=>false, 'error'=>'Unknown action', 'available'=>['get_fresh_accounts','check_licence','check_smtp','stats']]);
}