#!/usr/bin/env python3 # V84: Add file-based cache 5s to em-live-kpi.php (reduce 9.6s→ms via cache) path = "/var/www/html/api/em-live-kpi.php" with open(path, "rb") as f: raw = f.read() if b"V84 cache" in raw: print("ALREADY") exit(0) # Insert cache logic after 100) { @file_put_contents($_emcache, $out); } echo $out; }); ob_start(); """ if old in raw: idx = raw.find(old) raw = raw[:idx] + new + raw[idx+len(old):] with open(path, "wb") as f: f.write(raw) print(f"PATCHED size: {len(raw)}") else: print("PHP_TAG_NOT_FOUND")