Jump to content

Php open file


shage

Recommended Posts

Im trying to open a list of htm files, on those files find the </body> tag so i can add a include to all the files to call a footer so i dont have to change copywrite on all the pages but only have to change one, i didnt think about this long before, so now i have thousands of files that still say 1995 on the bottom of them thanks in advance

Link to comment
Share on other sites

Even using that wont remove the 1995 from current pages.

 

either, use a text editor that can do a search & replace over multiple files (UltraEdit is what I use)

or create a script to make these changes for u.

 

this can be done with php, and if the dates are in the same format, a preg_match/replace function to add in the new custom footer/code.

 

if ya need it done today, go with option 1

if it can wait a couple of days, consider option 2 (then u have a new tool in yer box)

Link to comment
Share on other sites

this might* work if you do it proper  actually it won't work properly, but i'll get you going and you can figure out out the reset that is

If you want to use a php include you will need to force your server to phrase html extensions (or .htm) as php files.

 

Also your files in the array must have a proper absolute internal address or a proper relative adderss to this scripts location

<?php
$files = array("file1.html","myfavs.htm","index.html");
$insert_line = "<p>Copyright © 2008</p>";
foreach($files as $value){
$temp_file = file_get_contents($files);
#Here you will need to explode apart said file so the positioning is right I will psedo this
$file_top = "TEMP FILE TOP PART";
$file_bottom = "TEMP FILE BOTTOM PART";
file_put_contents($value,$file_top.$insert_line.$file_bottom);
unset($temp_file);
}
?>

 

So you will need to figure out how to break apart the files (using regex or something similar) and then from there put the new line in its "sandwich"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.