Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl Regex Advice Needed

Alter Copyright at Top of Files

         

Birdman

1:06 pm on Apr 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The files belong to my client. He had another programmer add it at the top of all php files and he did it wrong. It's sending whitespace and causing errors on any page trying to use header(Location: ).

<?
//------------------------------------------------------------------------
// Program: *****************
// Version: 1.6
// Author: *****************
// URL: ******************
// Copyright (c) 2007 ******************
// All rights reserved.
//
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
//
//------------------------------------------------------------------------
?>

<?

I guess the easies way would be to remove the closing and opening PHP brackets at the end but I am not positive if every file has the copyright and there are alot of files.

How can I make sure the copyright is there and then replace the:

?>

<?

...with just some newlines or even nothing?

I appreciate any help as I'm not great at regex.

Thanks!

ps. I use Linux and plan to do this from a terminal command line.

[edited by: Birdman at 1:19 pm (utc) on April 6, 2007]

Birdman

3:54 pm on Apr 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've solved the problem. Found a nice prewritten script that worked perfectly.

If anyone needs it, Sticky me.