Jump to content

Search .php File for word


Dysan

Recommended Posts

first I would glob() all the php files:

 

This is just an example (not the real deal):

<?php
$find = '~'.$_POST['searchString'].'~';
foreach(glob($_POST['selectedDirectory'].'/*.php') as $filename){   // * stands for wild card
    $handle = fopen($filename, "r");
    $contents = fread($handle, filesize($filename));
    fclose($handle);
    if(preg_match($find,$contents,$matches)){
        echo 'Found a match: '.$matches[0].' in file: '.$filename;
    }
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.