need help for customizing PHP-grep files search
can somebody please help me with this issue...
i have installed PHP-grep on my website and it works well.. but that i need a little change in the script so that it displays the file with hyperlink in it instead of displaying the actual path.
would be really helpful if somebody help me..
below is the code that i have in my site www.linktoprofessionals.com/files
<?php
/**
* powered by @cafewebmaster.com
* free for private use
* please support us with donations
*/
define("SLASH", stristr($_SERVER[SERVER_SOFTWARE], "win") ? "\\" : "/");
$path = ($_POST[path]) ? $_POST[path]: dirname(__FILE__);
$q = $_POST[q];
function php_grep($q, $path){
$fp = opendir($path);
while($f = readdir($fp)){
if( preg_match("#^\.+$#", $f) ) continue;
$file_full_path = $path.SLASH.$f;
if(is_dir($file_full_path)) {
$ret .= php_grep($q, $file_full_path);
} else if( stristr(file_get_contents($file_full_path), $q) ) {
$ret .= "$file_full_path\n";
}
}
return $ret;
}
if($q){
$results = php_grep($q, $path);
}
echo <<
Query
$results
HRD;
?>
Similar entries
- Search in text files recursively with PHP - Grep
- Get Full Url Path excluding PHP Script's name
- Upload multiple images with PHP
- Repair all mysql databases-tables with PHP
- Smart Multi-Uploader and Thumbnail Creator from GIF/ JPEG/ PNG with PHP
- How to setup auto_prepend_file with safe mode and open basedir restriction
- Very simple and short PHP-Shell script
- Howto install Volatility (RAM / Memory Forensic Framework) in Windows
- How to recursively create md5 and sha1 sum of your files.
- Howto protect admin.php / login.php with htaccess password
- .htaccess examples
- Web2 style secure & flexible free php contact form with easy setup
- Url manipulation with mod_rewrite and php-catcher for beginners
- A small login to add to top of online testing scripts
- Filezilla and plain-text clear, unsecure password storage
- How to mount shared Folder in VirtualBox and Ubuntu Linux
- Import big SQL Files under WAMP or LAMP ?
- Redirect a query to multiple search engines with one form and javascript
- Search only in .php files under linux

change
$ret .= "$file_full_path\n";
to
$ret .= "< a href='$file_full_path' >$file_full_path< /a >\n";
I would love to have a 3rd box to replace the text found with a new text, I've tried with no success ... just like grep and sed ... can some one help ?
TKS
<?php
/**
* powered by @cafewebmaster.com
* free for private use
* please support us with donations
*/
define("SLASH", stristr($_SERVER[SERVER_SOFTWARE], "win") ? "\\" : "/");
$path = ($_POST[path]) ? $_POST[path] : dirname(__FILE__) ;
$q = $_POST[q];
$r = $_POST[r];
function php_grep($q, $path){
$fp = opendir($path);
while($f = readdir($fp)){
if( preg_match("#^\.+$#", $f) ) continue; // ignore symbolic links
$file_full_path = $path.SLASH.$f;
if(is_dir($file_full_path)) {
$ret .= php_grep($q, $file_full_path);
str_ireplace("$q","$r");
} else if( stristr(file_get_contents($file_full_path), $q) ) {
$ret .= "$file_full_path\n";
}
}
return $ret;
}
if($q){
$results = php_grep($q, $path);
}
echo <<
Path
old text
new text
$results
HRD;
?>
Hi,
I need some help, I'm using the PHP-grep with the following code and would like it to return individuals links if more than 1 file is found. Currently it concatenates to on link if there are multiple files found.
thanks
<?php
/**
* powered by @cafewebmaster.com
* free for private use
* please support us with donations
*/
define("SLASH", stristr($_SERVER[SERVER_SOFTWARE], "win") ? "\\" : "/");
$path = ($_POST[path]) ? $_POST[path] : dirname(__FILE__) ;
$q = $_POST[q];
function php_grep($q, $path){
$fp = opendir($path);
while($f = readdir($fp)){
if( preg_match("#^\.+$#", $f) ) continue; // ignore symbolic links
$file_full_path = $f;
if(is_dir($file_full_path)) {
$ret .= php_grep($q, $file_full_path);
} else if( stristr(file_get_contents($file_full_path), $q) ) {
$ret .= "$file_full_path". PHP_EOL;
}
}
return $ret;
}
if($q){
$results = php_grep($q, $path);
}
echo <<
Query
$results
HRD;
?>
Post new comment