Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   Help in deleting no right mouse click code from 10k of pages on server (http://www.greenguysboard.com/board/showthread.php?t=8227)

Cleo 2004-06-09 10:21 AM

Help in deleting no right mouse click code from 10k of pages on server
 
I've got over 10k in pages, 7 gigs total with images, that has no right mouse click code that I need to delete.

I have a few server scripts that will do search and replace on a server but they only work with one line of code at a time and if there is spaces in the file names and directories which seems to break the script and any of the pages and directories have spaces in the names. :(

I do already have a tar file downloaded so I may just have to do this locally and then re-upload everything but damn it is 7 gigs.

This is the code,

DangerDave 2004-06-09 05:01 PM

If you have the tar, you should only have to upload the changed HTML? yes?


I don't have a solution, but Ray - Webmastersguide/Strongbox, probably will... he should see this thread.

DD

venturi 2004-06-10 01:24 AM

Cleo,

UltraEdit has a very robust Global Search and Replace function built into it that will walk thru multiple files and directories that will do this for you easily. You can download a trial version of it at ultraedit.com and if you end up liking the product (I love it and have been using it for almost 10yrs) registration is only about $40.

Cleo 2004-06-10 07:05 AM

Looks like ultraedit.com is about the same thing as bbedit.com which I use all the time, but just like bbedit doesn't do batch find and replace on the server.

Actually I looked through more files and the code is slightly different in the way it is written in almost every page. |banghead|

I'm having a hell of a time getting the tarball to download from the server without it getting corrupt. Best can I do is 2.6 megs transfer speed with my cable modem so it takes something like 18 hours and then ends up being corrupt in the end.

I see that the server has rsync installed and my Mac also has rsync so I may end up mirroring the server's drive locally using rsync and just working on everything local. This way once it will still take a few days to get everything downloaded to my local drive but then only the changed files will get re-uploaded.

DangerDave 2004-06-10 05:43 PM

If you are going to do it locally...

Try - http://www.abacre.com/afr/index.htm (Win)

DD

Entreri 2004-06-10 10:29 PM

Wouldn't it be easier to correct one of your scripts so that they handle filenames and directories containing spaces and run your script in your shell? Although, constructing the actual search and replace regexp is going to be a challenge if the script you want to strip is slightly different in each pages as you mentionned. |dizzy| (Unless you want to remove all javascript, then it's nothing)

Also, I'm wondering why you're downloading the whole 7 gigs (including pictures) when you could download a tar containing only html files...

Entreri.

venturi 2004-06-11 04:16 AM

good point Entreri!

use the --exclude [pattern] parameter to exclude all the .jpg files in the tarball and you'll reduce the size quite a bit (assuming that there's a bit of content in your directories.

Cleo 2004-06-11 06:57 AM

Maybe I'm missing something but if I did a tar file and excluded the jpg, gif, wmv, etc. wouldn't I have a problem just replacing these files when I re-uploaded the html in keeping the directory structure as everything is in scatted nested directories all over the place?

DangerDave 2004-06-11 05:13 PM

Quote:

Maybe I'm missing something but if I did a tar file......
Not if the orig dir structure still existed? Are you moving the pages Cleo or just changing them?

DD

Cleo 2004-06-11 05:59 PM

To remove the code from the pages I don't have to move them. Can you un-tar something and have it replace only the html files while keeping the directories and files untouched?

But I'm thinking now it would probably be a good idea to also remove all the spaces from the directories, html files, and jpgs if I did decide to download this mess.

The more I think about it I'm thinking it would probably be best to download one directory at a time and fix them slowly. I have very good find and replace tools on my Mac including a nice editor with Grep and GoLive as some very good site site maintenance tools for getting rid of all the spaces and fixing broken links.

DangerDave 2004-06-11 06:02 PM

Quote:

Can you un-tar something and have it replace only the html files while keeping the directories and files untouched?
Yes you can:)

DD

Cleo 2004-06-11 06:26 PM

Quote:

Originally posted by DangerDave
Yes you can:)

DD

Guess it is time for the man tar pages LOL

swedguy 2004-06-13 09:53 AM

http://www.sponsororganizer.com/FreeScripts/cleo.html

Save the script as cleo.pl

Chmod it to 755

Run:
find /main/domain/dir \( -name '*.html' -o -name '*.php' -o -name '*.htm' \) -exec cleo.pl {} \;

It will run through all your .html, .php and .htm files and delete the code.
Remember that it will open and save all files, even the ones that doesn't have the code in it (it will just not change anything). So if you have any files that are owned by the webserver user, it _might_ change the owner to the user you run the script as.

I made a test run here on a bunch of files with and without the code in, and it worked like a charm. A hot advice is to make a test run in a temp folder :)

My ICQ is 252081 if you need any help.
Good luck if you decide to use it :)

swed

Cleo 2004-06-13 10:03 AM

This looks interesting.

Could I do

find /home/foxy/web/members \( -name '*.html' -o -name '*.php' -o -name '*.htm' \) -exec ../../myscripts/remove-right-mouse-code.pl {} \;

and this way it would only do the member's directory?

swedguy 2004-06-13 10:19 AM

Quote:

Originally posted by Cleo
This looks interesting.

Could I do

find /home/foxy/web/members \( -name '*.html' -o -name '*.php' -o -name '*.htm' \) -exec ../../myscripts/remove-right-mouse-code.pl {} \;

and this way it would only do the member's directory?

It will do the /home/foxy/web/members directory and all it's sub-dirs.

If you only want to do the /home/foxy/web/members dir and no sub-dirs... do this:

find /home/foxy/web/members \( -name '*.html' -o -name '*.php' -o -name '*.htm' \) -maxdepth 1 -exec ../../myscripts/remove-right-mouse-code.pl {} \;

Cleo 2004-06-13 11:07 AM

Something is wrong.

I'm getting this.

../../myscripts/remove-right-mouse-code.pl: line 5: syntax error near unexpected token `s/(/<'
../../myscripts/remove-right-mouse-code.pl: line 5: `s/(/
2. Or, you could add comments that act as tags around code to clearly identify those blocks.

Code:




Then, if you think one of the files does not use the same block of code, or you want to modify the block of code, or remove it altogether, those tags make it very easy to do so.

Entreri.

Cleo 2004-06-14 07:30 AM

Yeah I made a tarball of the whole site before running this just incase something went horribly wrong.

As for the code I would never do something like this. This whole site was done in FrontPage with the server extensions by someone that had no idea what they were doing over 6 years.

I've looked through many of the pages and have yet to find any pages with this code still in them so it looks like this worked extremely well.

Rorschach 2004-06-17 10:25 PM

*cough*

man sed


All times are GMT -4. The time now is 02:58 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc