Skip to content

Instantly share code, notes, and snippets.

@divinity76
Created January 18, 2024 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divinity76/62f19b4b2bb50b5f19a51ddd1d421d1e to your computer and use it in GitHub Desktop.
Save divinity76/62f19b4b2bb50b5f19a51ddd1d421d1e to your computer and use it in GitHub Desktop.
file searcher
<?php
declare(strict_types=1);
$dir = realpath(__DIR__ . '/..');
$files = shell_exec("find " . escapeshellarg($dir) . " -print0");
$files = explode("\x00", rtrim($files, "\x00"));
$files = array_filter($files, function ($filepath) {
if (!preg_match("/page/", $filepath)) {
return false;
}
if (!preg_match("/\.php$/", $filepath)) {
return false;
}
$content = file_get_contents($filepath);
if (!preg_match("/getBody/", $content)) {
return false;
}
return true;
});
var_dump($files);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment