At 11:27 AM 4/30/2004, John W. Holmes wrote:
From: "Steve Buehler" <[EMAIL PROTECTED]>

> #!/usr/bin/php
> <?
> $strtoreplace="require \"http://www.domain.com/";;
> $replacewithstring="require \"/home/domain/www/";
>
> replacestring();
>
> function replacestring(){
> GLOBAL $strtoreplace,$replacewithstring;
>          $FILES=array(`ls -1 */*|grep .php`);
>          foreach($FILES as $value){
>                  if($value){
>                          echo "file $value\n";

$content = file_get_contents($value);
$content = str_replace($strtoreplace,$replacewithstring,$content);
$fp = fopen($value,'w');
fwrite($fp,$content);
fclose($fp);

>                  }
>          }
> }
> ?>

You could use glob() to get the list of files, too.

$FILES = glob('*.php');

---John Holmes...

John
Thank you so much for this. I was thinking of it all wrong when doing this. I have a couple of other questions to go along with this.
1. How would I change this to do a recursive search for the .php files instead of just the *.php or */*.php in the glob?
2. I also have some dns zone files that I was going to modify this script to replace some information in them. What it would have to do is to delete all lines that have white space (could be a space or a tab) NS more white space and then add specific lines that I want in place of the deleted lines.
2.a. There will normally be between 2 and 4 lines that I want deleted and 2 to replace them.


If you don't want to answer this one, that is fine. There are only about 200 zone files and that wouldn't take as long for me to do manually as it would have for the .php file changes.

Thanks
Steve

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to