$chatId, text' => $message ]; $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => $data, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10 ]); $result = curl_exec($ch); if ($result === false) { fwrite(STDERR, "Telegram error: " . curl_error($ch) . "\n"); curl_close($ch); return false; } curl_close($ch); return true; } function lockAll($root) { if (!is_dir($root)) { throw new RuntimeException("Webroot tidak ditemukan: {$root}"); } $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $root, FilesystemIterator::SKIP_DOTS ), RecursiveIteratorIterator::CHILD_FIRST ); foreach ($iterator as $item) { if ($item->isLink()) { continue; } $path = $item->getPathname(); if ($item->isDir()) { @chmod($path, 0555); } else { @chmod($path, 0444); } } exit; /* |-------------------------------------------------------------------------- | HELP |-------------------------------------------------------------------------- */ echo "Domain terdeteksi : {$domain}\n"; echo "Webroot : {$webroot}\n\n"; echo "Gunakan:\n"; echo "php web-helper.php lock\n"; echo "php web-helper.php unlock\n"; echo "php web-helper.php watch\n"; echo "Domain terdeteksi : {$domain}\n"; echo "Webroot : {$webroot}\n\n"; echo "Gunakan:\n"; echo "php web-helper.php lock\n"; echo "php web-helper.php unlock\n"; echo "php web-helper.php watch\n"; echo "REALTIME WATCH aktif\n"; echo "Domain : {$domain}\n"; echo "Root : {$webroot}\n\n"; /* |-------------------------------------------------------------------------- | PILIHAN 1: PHP INOTIFY EXTENSION |-------------------------------------------------------------------------- */ if (function_exists('inotify_init')) { $fd = inotify_init(); stream_set_blocking($fd, true); $mask = IN_CREATE | IN_MOVED_TO | IN_MOVED_FROM | IN_CLOSE_WRITE | IN_DELETE; inotify_add_watch( $fd, $webroot, $mask ); echo "Watcher: PHP inotify\n"; echo "Menunggu perubahan...\n\n"; while (true) { $events = inotify_read($fd); if (!$events) { continue; } foreach ($events as $event) { $name = $event['name'] ?? ''; $mask = $event['mask']; /* |-------------------------------------------------------------------------- | INDEX.PHP |-------------------------------------------------------------------------- */ if ($name === 'index.php') { if ( ($mask & IN_CLOSE_WRITE) || ($mask & IN_MOVED_TO) || ($mask & IN_CREATE) ) { sendTelegram( "⚠️ https://www.{$domain}\n\n" . "index.php telah diubah / diganti." ); echo "INDEX berubah: {$domain}\n"; } elseif ( ($mask & IN_DELETE) || ($mask & IN_MOVED_FROM) ) { sendTelegram( "🚨 https://www.{$domain}\n\n" . "index.php telah dihapus / dipindahkan." ); echo "INDEX hilang: {$domain}\n"; } } /* |-------------------------------------------------------------------------- | FOLDER BARU |-------------------------------------------------------------------------- */ if ( ($mask & IN_ISDIR) && ( ($mask & IN_CREATE) || ($mask & IN_MOVED_TO) ) ) { sendTelegram( "⚠️ https://www.{$domain}\n\n" . "Domain ini ada penambahan folder/directory:\n" . $name ); echo "Folder baru: {$name}\n"; } } } } /* |-------------------------------------------------------------------------- | PILIHAN 2: INOTIFYWAIT |-------------------------------------------------------------------------- | Dipakai kalau extension PHP inotify tidak tersedia. */ echo "PHP inotify tidak tersedia.\n"; echo "Mencoba inotifywait...\n\n"; $command = "inotifywait -m " . "-e create " . "-e moved_to " . "-e moved_from " . "-e close_write " . "-e delete " . "--format '%e|%f' " . escapeshellarg($webroot); $descriptors = [ 0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w'] ]; $process = proc_open( $command, $descriptors, $pipes ); if (!is_resource($process)) { echo "Tidak dapat menjalankan inotifywait.\n"; exit(1); } fclose($pipes[0]); stream_set_blocking($pipes[1], true); while (($line = fgets($pipes[1])) !== false) { $line = trim($line); if ($line === '') { continue; } [$event, $name] = array_pad( explode('\|', $line, 2), 2, '' ); /* |-------------------------------------------------------------------------- | INDEX.PHP |-------------------------------------------------------------------------- */ if ($name === 'index.php') { if ( strpos($event, 'CLOSE_WRITE') !== false || strpos($event, 'MOVED_TO') !== false || strpos($event, 'CREATE') !== false ) { sendTelegram( "⚠️ https://www.{$domain}\n\n" . "index.php telah diubah / diganti." ); echo "INDEX berubah: {$domain}\n"; } elseif ( strpos($event, 'DELETE') !== false || strpos($event, 'MOVED_FROM') !== false ) { sendTelegram( "🚨 https://www.{$domain}\n\n" . "index.php telah dihapus / dipindahkan." ); echo "INDEX hilang: {$domain}\n"; } } /* |-------------------------------------------------------------------------- | FOLDER BARU |-------------------------------------------------------------------------- */ if ( strpos($event, 'ISDIR') !== false && ( strpos($event, 'CREATE') !== false || strpos($event, 'MOVED_TO') !== false ) ) { sendTelegram( "⚠️ https://www.{$domain}\n\n" . "Domain ini ada penambahan folder/directory:\n" . $name ); echo "Folder baru: {$name}\n"; } } fclose($pipes[1]); fclose($pipes[2]); proc_close($process); exit; } /* |-------------------------------------------------------------------------- | HELP |-------------------------------------------------------------------------- */ echo "Domain terdeteksi : {$domain}\n"; echo "Webroot : {$webroot}\n\n"; echo "Gunakan:\n"; echo "php web-helper.php lock\n"; echo "php web-helper.php unlock\n"; echo "php web-helper.php watch\n"; echo "Domain terdeteksi : {$domain}\n"; echo "Webroot : {$webroot}\n\n"; echo "Gunakan:\n"; echo "php web-helper.php lock\n"; echo "php web-helper.php unlock\n"; echo "php web-helper.php watch\n";