118 lines
5.7 KiB
PHP
118 lines
5.7 KiB
PHP
<?php
|
|
ignore_user_abort(true);
|
|
set_time_limit(300);
|
|
header('Content-Type: application/json');
|
|
$r = [];
|
|
|
|
// ═══ FIX 1: L99 CRON LINE 433 ═══
|
|
$l99 = file_get_contents("/opt/weval-l99/l99-master.py");
|
|
// Fix the broken line: "crontab -l 2>/dev/null; sudo crontab -l 2>/dev/null | grep..."
|
|
// Replace with: "sudo crontab -l 2>/dev/null | grep -v '^#' | grep -v '^$' | wc -l"
|
|
$l99 = str_replace(
|
|
'crontab -l 2>/dev/null; sudo crontab -l 2>/dev/null',
|
|
'sudo crontab -l 2>/dev/null',
|
|
$l99
|
|
);
|
|
file_put_contents("/opt/weval-l99/l99-master.py", $l99);
|
|
$r['l99_cron'] = 'fixed line 433';
|
|
|
|
// ═══ FIX 2: ARSENAL PROXY — serve from S204 instead of S95 ═══
|
|
// warmup-manager exists as PHP at /var/www/weval/arsenal/warmup-manager.php
|
|
// Create an HTML redirect/proxy
|
|
$warmup_html = file_get_contents("/var/www/weval/arsenal/warmup-manager.php");
|
|
if ($warmup_html) {
|
|
file_put_contents("/var/www/html/warmup-manager.html", $warmup_html);
|
|
$r['arsenal'] = 'warmup-manager.html created from PHP source';
|
|
} else {
|
|
// Create simple placeholder
|
|
$html = '<!DOCTYPE html><html lang="fr"><head><meta charset="UTF-8"><title>Warmup Manager</title></head><body style="background:#0a0e1a;color:#e2e8f0;font-family:monospace;padding:40px"><h1>🔥 Warmup Manager</h1><p>Service intégré dans WEVADS Arsenal.</p><p><a href="/wevads-ia/" style="color:#6d28d9">→ Accéder à WEVADS IA</a></p></body></html>';
|
|
file_put_contents("/var/www/html/warmup-manager.html", $html);
|
|
$r['arsenal'] = 'placeholder created';
|
|
}
|
|
|
|
// ═══ FIX 3: LOKI — restart with --network host ═══
|
|
$loki_status = trim(shell_exec("docker ps --filter name=loki --format '{{.Status}}' 2>/dev/null"));
|
|
if (!$loki_status) {
|
|
// Try to start Loki with --network host
|
|
shell_exec("sudo docker rm -f loki 2>/dev/null");
|
|
shell_exec("sudo docker run -d --name loki --network host --restart unless-stopped -v /opt/loki-data:/loki grafana/loki:latest -config.file=/etc/loki/local-config.yaml 2>&1");
|
|
sleep(5);
|
|
$loki_status = trim(shell_exec("docker ps --filter name=loki --format '{{.Status}}' 2>/dev/null"));
|
|
$r['loki'] = $loki_status ?: 'failed to start';
|
|
} else {
|
|
$r['loki'] = "already running: $loki_status";
|
|
}
|
|
|
|
// ═══ FIX 4: PAPERCLIP — restart + add keepalive cron ═══
|
|
shell_exec("sudo pkill -9 -f paperclipai 2>/dev/null");
|
|
sleep(2);
|
|
shell_exec("sudo bash -c 'cd /opt/paperclip-weval && nohup env ANTHROPIC_BASE_URL=https://weval-consulting.com/api/wevia-anthropic.php ANTHROPIC_API_KEY=wevia-sovereign-key DATABASE_URL=postgres://paperclip:PaperclipWeval2026@127.0.0.1:5432/paperclip PORT=3100 npx paperclipai run >> /var/log/paperclip.log 2>&1 &'");
|
|
sleep(8);
|
|
$pc_http = (int)trim(shell_exec("curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3100/ 2>/dev/null"));
|
|
$r['paperclip'] = "HTTP $pc_http";
|
|
|
|
// Add keepalive cron (check every 5 min, restart if down)
|
|
$keepalive = '*/5 * * * * curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3100/ 2>/dev/null | grep -q 200 || (cd /opt/paperclip-weval && sudo pkill -f paperclipai; sleep 2; nohup env ANTHROPIC_BASE_URL=https://weval-consulting.com/api/wevia-anthropic.php ANTHROPIC_API_KEY=wevia-sovereign-key DATABASE_URL=postgres://paperclip:PaperclipWeval2026@127.0.0.1:5432/paperclip PORT=3100 npx paperclipai run >> /var/log/paperclip.log 2>&1 &)';
|
|
$existing_cron = shell_exec("crontab -l 2>/dev/null");
|
|
if (strpos($existing_cron, 'paperclipai') === false) {
|
|
shell_exec("(crontab -l 2>/dev/null; echo '$keepalive') | crontab -");
|
|
$r['paperclip_cron'] = 'keepalive added';
|
|
} else {
|
|
$r['paperclip_cron'] = 'already exists';
|
|
}
|
|
|
|
// ═══ FIX 5: L99 CSS LEAK — inject hide rule ═══
|
|
// The CSS "Day/Night Theme Toggle" is injected by React runtime
|
|
// Add CSS rule in the page to hide any raw CSS text rendered as body content
|
|
// Since we can't modify the React bundle, inject a fix via weval-faq-fix.js
|
|
$faq = file_get_contents("/var/www/html/weval-faq-fix.js");
|
|
if (strpos($faq, 'hideCSSLeak') === false) {
|
|
$css_fix = '
|
|
/* Fix CSS leak in L99/Brain pages */
|
|
(function hideCSSLeak(){
|
|
var b=document.body;
|
|
if(!b)return;
|
|
var nodes=b.childNodes;
|
|
for(var i=0;i<nodes.length;i++){
|
|
var n=nodes[i];
|
|
if(n.nodeType===3 && n.textContent && n.textContent.indexOf("data-theme")>-1){
|
|
n.textContent="";
|
|
}
|
|
}
|
|
// Also hide any text node containing CSS code
|
|
setTimeout(function(){
|
|
var all=document.querySelectorAll("body > *");
|
|
for(var j=0;j<all.length;j++){
|
|
var el=all[j];
|
|
if(el.tagName!=="STYLE" && el.tagName!=="SCRIPT" && el.textContent &&
|
|
el.textContent.indexOf("weval-theme-btn")>-1 && el.textContent.indexOf("{")>-1) {
|
|
el.style.display="none";
|
|
}
|
|
}
|
|
},500);
|
|
})();
|
|
';
|
|
file_put_contents("/var/www/html/weval-faq-fix.js", $faq . $css_fix);
|
|
$r['css_leak'] = 'hide fix injected in faq-fix.js';
|
|
} else {
|
|
$r['css_leak'] = 'already fixed';
|
|
}
|
|
|
|
// ═══ FIX 6: OPCACHE RESET ═══
|
|
opcache_reset();
|
|
$r['opcache'] = 'reset';
|
|
|
|
// ═══ VERIFY ═══
|
|
sleep(2);
|
|
$checks = [
|
|
'paperclip' => (int)trim(shell_exec("curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3100/ 2>/dev/null")),
|
|
'wedroid' => (int)trim(shell_exec("curl -s -o /dev/null -w '%{http_code}' 'https://weval-consulting.com/api/wedroid-brain-api.php?k=DROID2026&action=status' 2>/dev/null")),
|
|
'warmup' => (int)trim(shell_exec("curl -s -o /dev/null -w '%{http_code}' 'https://weval-consulting.com/warmup-manager.html' 2>/dev/null")),
|
|
'loki' => (int)trim(shell_exec("docker ps --filter name=loki --format '{{.Status}}' 2>/dev/null | wc -c")),
|
|
'docker_total' => (int)trim(shell_exec("docker ps --format '{{.Names}}' | wc -l")),
|
|
];
|
|
$r['verify'] = $checks;
|
|
|
|
echo json_encode(["ok"=>true, "results"=>$r], JSON_PRETTY_PRINT);
|
|
unlink(__FILE__);
|