Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type: text/plain');
- /* _____ _____ _ _____ _____ _____ _____ _____ _____
- ___| | __ |_| _ |_ _|___ ___|_ _| __| _ | |
- |_ -| --| -| | __| | | |- _|___| | | | __| | | | |
- |___|_____|__|__|_|__| |_| |___| |_| |_____|__|__|_|_|_|
- |s C R i P T z - T E A M . i N F O|████████████████████████████
- $arr -> array of files, for us it was file1.log and file2.log,
- dont forget to write the filename without extension, since its
- handled in "$file = "./__logs/" . $value . ".log";" so just
- replace that extension .log to any you need, like .txt or .sql
- */
- //set_time_limit(0); -> Needed if you searching in big files for long time
- //ini_set('memory_limit', '800M'); -> Needed if you searching in big files
- $arr = array(
- "file1",
- "file2"
- );
- foreach ($arr as &$value) {
- $file = "./__logs/" . $value . ".log";
- $searchfor = '';
- $contents = file_get_contents($file);
- $pattern = preg_quote($searchfor, '/');
- $pattern = "/^.*$pattern.*\$/m";
- if (preg_match_all($pattern, $contents, $matches)) {
- echo "Found:\n";
- echo implode("\n", $matches[0]);
- } else {
- echo "No match!";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement