search and replace

Discussion in 'PHP' started by gigamike, Aug 3, 2007.

  1. #1
    Hi Guys,

    I hope you can help me. Do you think its possible to create a .php script that search and replace all string to all files. I was able to make it but the problem is that if the file chmod is is not writable, i aint able to replace the search string. Maybe a commandline will do, any idea.

    Thanks,

    Mike
     
    gigamike, Aug 3, 2007 IP
  2. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #2
    What have you already tried to code to do this for you? Which part of that code is not working correctly for you?
     
    exodus, Aug 3, 2007 IP
  3. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Hi,

    i did some and it works wherein ill scan all files in a given directory and used fopen then str_replace. Now my problem is that i want to be able to maintain the chmod of the file uploaded via ftp. Coz when a file is uploaded via ftp, its 644 which is not writable.

    Im thinking if its possible a command line for search and replace but my worry is that even my own script will be altered. Any ideas ?

    Thanks,

    mike
     
    gigamike, Aug 3, 2007 IP
  4. daman371

    daman371 Peon

    Messages:
    121
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can make the file writeable using ftp.
     
    daman371, Aug 11, 2007 IP
  5. coderlinks

    coderlinks Peon

    Messages:
    282
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hello,
    Check out the chmod function. You may be able to change permissions as you go. Also you can use the dir class to interate through the files in a directory.

    ~
    Thomas
     
    coderlinks, Aug 12, 2007 IP