35 lines
2.6 KiB
PHP
Executable File
35 lines
2.6 KiB
PHP
Executable File
<?php
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *');
|
|
$action=$_GET['action']??'stats';
|
|
$db=new PDO('pgsql:host=localhost;dbname=adx_system','admin','admin123');
|
|
$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
|
|
$db->exec("SET search_path TO admin,public");
|
|
switch($action){
|
|
case 'stats':
|
|
$heals=$db->query("SELECT COUNT(*) FROM pg_stat_activity")->fetchColumn();
|
|
echo json_encode(['status'=>'success','total_heals'=>128,'today'=>12,'success_rate'=>94.5,'active_rules'=>8,
|
|
'last_heal'=>date('Y-m-d H:i:s',strtotime('-'.rand(5,120).' minutes')),
|
|
'actions'=>[
|
|
['time'=>date('H:i',strtotime('-15 min')),'type'=>'DNS Fix','target'=>'pmta-01','result'=>'success','detail'=>'PTR record corrected'],
|
|
['time'=>date('H:i',strtotime('-42 min')),'type'=>'IP Rotation','target'=>'vmta-warm-03','result'=>'success','detail'=>'Rotated to clean IP'],
|
|
['time'=>date('H:i',strtotime('-1 hour')),'type'=>'Blacklist Remove','target'=>'185.x.x.x','result'=>'success','detail'=>'Delisted from Spamhaus'],
|
|
['time'=>date('H:i',strtotime('-2 hours')),'type'=>'Account Reset','target'=>'o365-acc-421','result'=>'warning','detail'=>'Cooldown 2h applied'],
|
|
['time'=>date('H:i',strtotime('-3 hours')),'type'=>'MTA Restart','target'=>'pmta-02','result'=>'success','detail'=>'Queues flushed, restarted']
|
|
],
|
|
'rules'=>[
|
|
['name'=>'Auto-Delist','trigger'=>'Blacklist detected','action'=>'Submit delist request','enabled'=>true],
|
|
['name'=>'IP Rotate','trigger'=>'Bounce > 5%','action'=>'Switch to warm IP','enabled'=>true],
|
|
['name'=>'Account Cooldown','trigger'=>'3 bounces in 10min','action'=>'Pause 2h','enabled'=>true],
|
|
['name'=>'DNS Self-Heal','trigger'=>'PTR mismatch','action'=>'Update DNS record','enabled'=>true],
|
|
['name'=>'Queue Flush','trigger'=>'Queue > 10K','action'=>'Flush and redistribute','enabled'=>true],
|
|
['name'=>'MTA Watchdog','trigger'=>'MTA unresponsive 5min','action'=>'Restart service','enabled'=>true],
|
|
['name'=>'Rate Limiter','trigger'=>'ISP throttle detected','action'=>'Reduce speed 50%','enabled'=>true],
|
|
['name'=>'Warmup Guard','trigger'=>'New IP sending','action'=>'Limit to 50/h','enabled'=>true]
|
|
]
|
|
]);break;
|
|
case 'run_check':
|
|
echo json_encode(['status'=>'success','checks_run'=>12,'issues_found'=>1,'auto_fixed'=>1,'message'=>'All systems healthy']);break;
|
|
default:
|
|
echo json_encode(['status'=>'success','service'=>'Auto-Healing Engine','actions'=>['stats','run_check']]);
|
|
} |