Web Analytics Made Easy -
StatCounter Can this be done with php ? - CodingForum

Announcement

Collapse
No announcement yet.

Can this be done with php ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can this be done with php ?

    A very interesting idea ... but can php do it ?

    I completed my website a while ago and now I
    need to change the phrase "have been" to "were"
    pretty much throughout the site. (there are a couple of other global changes
    that ı want to do as well).

    In order to speed this up and to have a useful utility for the future,
    I was thinking of somehow looking at all the pages in the website and searching for that phrase, logging it and the page it appears on. If I put my
    search phases in an array - one pass would find them all !

    Although I am pretty good at php and mysql use, I am not sure if this job can be done with php ?

    I would like to put the php script on my home server and scan the pages of my site - which is hosted by a hosting company.

    After running it I would have a list of where my phrases are and on what pages and then I could easily go and edit my code.

    Any ideas how I go about this ?

    I am not sure about how to start
    for example how do I get the script to look at www.mydomain.com ?


    And then I need to search each line of the HTML fro my phrase
    eg search for $phrase1 , $phrase2, $phrase3 ?

    Many thanks for suggestions and help ?
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #2
    Any decent version control software package does this kind of thing for you. If you are the sole developer (and therefore the only one changing the files) then you could just use something like Agent Ransack (freeware). I'm not sure why you want to write your own script to accomplish something that is well covered by search software already available...?

    Comment


    • #3
      from the root of your site, on a *nix command line:
      grep -r 'have been' .

      will give you a list of files, line numbers and the contents of the line in question.

      If you decide that every single match wants to be replaced, then something along the lines of
      grep -r 'have been' | sed -i "s/have been/were/"

      might do it....make a backup first.
      My thoughts on some things: http://codemeetsmusic.com
      And my scrapbook of cool things: http://gjones.tumblr.com

      Comment


      • #4
        better you should use this to that http://www.rjlsoftware.com/software/utility/search/

        it will not take more then 2-3 sec

        Thx

        Comment


        • #5
          Hello
          Thanks for all your replies.

          Maybe I wasn't very clear but I do want to do the search remotely because I dont want to touch the php code that is in the scripts - just the output that the browser would normally see.

          I would want to write the script to look at my live online website and follow all the links so that the whole site is checked by just starting with the index page.

          There is software out that does this sort of thing eg website download s/w they work remotely - looks at and can download a complete website by following links. I guess its that technolgy that I need - but can it be done in
          in PHP ?

          I dont need to (or want to) download the website just log the page that the phrase appears on so that I end up with a list.
          Assuming I have this array(have been, Mr Wilson)

          I'd like to get a list like this:

          /cafe/staff/memo5.php have been
          /cafe/staff/memo21.php Mr Wilson
          /cafe/menu/ss56.php have been
          ...

          Is this possible with php or would I have to write it in c
          or visual basic ? I would rather do it in php
          because thats all I know and I dont want to learn
          vb just for one little utility.

          If it can be done in php please - some more guidance.
          Thanks
          If you want to attract and keep more clients, then offer great customer support.

          Support-Focus.com. automates the process and gives you a trust seal to place on your website.
          I recommend that you at least take the 30 day free trial.

          Comment


          • #6
            First - Thanks for the link for Simple Search
            I will use this utlity for doing the second part of the job - the
            replacing - but I still want to do my online search that just looks at output from my live website.

            Apparently I need to use fopen ???

            Can anyone give me some further advice as I haven't done anything like this before
            If you want to attract and keep more clients, then offer great customer support.

            Support-Focus.com. automates the process and gives you a trust seal to place on your website.
            I recommend that you at least take the 30 day free trial.

            Comment


            • #7
              In order to look at what PHP produces I think you'd have to send every page to the buffer and then use ob_get_contents() to save the entire output in a variable, then do a search on that variable for the text you're looking for. Or something like that.

              There's probably a much better way....

              Comment

              Working...
              X