Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2008
    Location
    St. John's, NL
    Posts
    2,114

    text replacement help please

    Hi guys,

    I am upgrading a server (for a client) to php5 that has about 75 small sites (php + basic forms and feedback). Some of these sites were coded back in the day and use the old $HTTP_GET_VARS, $HTTP_POST_VARS and $HTTP_SERVER_VARS.

    I would rather not set register_long_arrays = On to be safe.

    I have root access to the server and all sites are stored under /home.

    Is there a way to automatically replace the above variables with the current ones ($_GET, $_POST, and $_SERVER) in every .php file. I know some combination of the find, sed, and xargs commands (shell) is needed, but not sure the syntax required.

    If someone could post an example, it would be appreciated.
    Cpanel/WHM PHP Perl Ruby Full Time Support
    LCWSoft - Canada web hosting (based in Newfoundland) since 2007
    Servers based in the US and Canada (Uptime Report)

  2. #2
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,342
    Sure, you can use PHP with str_replace. You can also use command prompt in linux/unix (I don't know how, but it should be doable with one or two lines).

    Peace,
    Testing 1.. Testing 1..2.. Testing 1..2..3...

  3. #3
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,842
    Not necessarily the most elegant way but you could do something like:
    Code:
    grep -lr HTTP_GET_VARS /home |grep "\.php" |xargs sed -ie "s/HTTP_GET_VARS/_GET/g"
    sed, used like that, will create backup files named .phpe - once you're sure it's done you'll want to remove these, eg. with
    Code:
    find /home -name \*.phpe |xargs rm -f
    Backup first, obviously, and you might also want to test on a small subdirectory, eg. /home/user/public_html/test
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  4. #4
    Join Date
    Jan 2008
    Location
    St. John's, NL
    Posts
    2,114
    Will that go through folders recursively?
    Quote Originally Posted by foobic View Post
    Not necessarily the most elegant way but you could do something like:
    Code:
    grep -lr HTTP_GET_VARS /home |grep "\.php" |xargs sed -ie "s/HTTP_GET_VARS/_GET/g"
    sed, used like that, will create backup files named .phpe - once you're sure it's done you'll want to remove these, eg. with
    Code:
    find /home -name \*.phpe |xargs rm -f
    Backup first, obviously, and you might also want to test on a small subdirectory, eg. /home/user/public_html/test
    Cpanel/WHM PHP Perl Ruby Full Time Support
    LCWSoft - Canada web hosting (based in Newfoundland) since 2007
    Servers based in the US and Canada (Uptime Report)

  5. #5
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,842
    Yes (grep -r = recursive)
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  6. #6
    Join Date
    Dec 2007
    Location
    Jakarta
    Posts
    113
    great, thanks i have same problem too

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •