ServertoSite.com    Find our open source software below : ): )

Clean Strip File. A PHP Script that Targets Via the Use of Markers, Multiple Sections (or Singular) You Choose in a File to be Isolated and Stripped from that Chosen File for Further Processing or to Display to a Web User Immediately

These scripts have hacker protection built in. For clean sanitized output from the scripts.

For a live demonstration of this script. simply click on either of the two main menu headings on this website, servertosite.com while ignoring the drop down menus. You will then be sent to a web page on this site which contains the identical script as shown below and the script will show you the requested sub menu items for that menu heading after it has stripped them from the header text file of this website, also pay attention to the look of the URL when clicking.

Benefits of Using Clean Strip File on This Website

The benefit of using the Clean Strip File script for me, is that when I add more sub menu items to my header text file, the script will automatically add them to the requested results when visitors request my sub menu page, so I do not have to waste time manually making a menu repeated times and making sure to remember to update each menu when more links are added.

The License Details

Clean Strip File is a PHP script released under the Creative Commons Open Source BSD License. You can legally use the Clean Strip File in as many of your own websites/applications or other peoples websites/applications as you like, that includes clients websites and applications, so long as you leave our credits in the top of the Clean Strip File scripts you use, even if Clean Strip File is integrated into another script. You are not required to put a link from any of your websites or web pages you use the Mivardia theme on back to us. Just enjoy the theme. Click here if you want to visit the creativecommons.org website and read the BSD license details. They are very liberal.

.........V Download Scripts V.........

Click here to download all four Clean Strip File PHP scripts shown below in a zip file

All Clean Strip File scripts are version 1.0 released late January 2011. All are stable and ready to use straight away

Clean Strip File Script Type 1 (Standard). For Larger Files Use The Next Script Below This One

Instructions on how to use the above script to target various parts in a file containing HTML or in an XML file:

First make sure that you put the path to the file you want to strip sections of HTML from between the ' ' in connection with the variable named fi just under where I have commented in the script //Path to file to be stripped. The path in the script above is set as if it were going to be used with our low maintenance web project and the script is pointing at and will read a text file named header.txt which is in a folder named clds. The text file is filled with HTML and I had the script targeted to grab submenu items from the menu of the website package, you can of course change that path to what ever you want.

Step two, start putting HTML comment tags around the parts of HTML or XML that you want to isolate:

Make a HTML comment tags around the <!-- first section end --> first part of the file we want to target and then close off the first part you want to target by making and ending <!-- first section end --> HTML comment tag, but giving it the same name at the beginning, like in this written example using the word 'first'. Please leave a gap between the start of the HTML comment and the key word, just like I have written in the example in this paragraph. Obviously I left a gap after the HTML tag in the script itself in front of the define variable. Now repeat. Note that these same HTML comment tags work exactly the same in an XML file also, so if you are targeting a pure XML file just do exactly the same thing, just make sure the path in the script points to an xml file obviously.

Step two note: Does it have to be HTML I am targeting? Can I target other type of files:

The answer is yes, so long as there are comments available for the file and what you want to extract from the file is not server side processed, like for example PHP code from inside a PHP file for example won't work as it is never available for public viewing and is processed server side. Read the next paragraph for an example of targeting CSS out from a CSS file.

To target CSS in a CSS file you will need to change the comment tags to CSS compatible comment tags. This means that you would go to the define variable in the script and change <!-- to the CSS equivalent of /* to replace it, you would then make CSS /* first section start */ and /* first section end */ comments around CSS you want to target. and repeat depending on how many different bits of CSS you need to target from that file.

How do I get results back from individual parts of a file I have targeted? Read all the paragraphs below for your answer. The first paragraph may not make sense to some people until they see the visual example under the third paragraph below

Any URL pointing to the script followed by a ? question mark and then the word menu, followed by an = sign and the name of the key word you want to target in the file in the HTML/XML/CSS comments, then followed by an ampersand symbol and then the letter c followed by an = sign and a number, likely a two digit number that will be used to crop or increase parts of the comment tag to stop the bits of the comment tag or unwanted HTML coming up in your results. You obviously do not want any part of the comment tag coming up in your results, so adjust the number until none shows in your results, or if you are good at maths, figure something out.

I hope the above paragraph made at least some sense, but I think a real example as used on this website may help. I use a script exactly the same as the above script on this website to isolate the sub menus on this site, so if someone does not use the drop down menu and clicks directly on a main menu they will be taken to the script which will then strip the HTML for the sub menu they want from the header text file of this website and echo out (display) the results to the user and they can then click on the submenu items without even knowing what happened unless they are tech savvy.

Example of a URL on this website servertosite.com  shown below it is directed at a script identical to the above script being used in real time right now on this website, the URL below is for the first main menu item on this website named Free Open Source Projects. The script will then strip out the sub menu because I have put HTML comments around the sub menu in the header text file of this website. Also note that sub.html shown in the URL is a PHP file containing the script:

http://servertosite.com/sub.html?menu=projects&c=21

Isolating chosen areas from files using comment tags

I have also isolated the sub menu related to the other main menu heading on this website servertosite.com, a heading named Useful Information. The URL is below, I have made HTML comments with the name of information as the first word (the target word) the script is then sent a URL with menu=information in it meaning the correct sub menu will be isolated. It is then displayed to a web user who clicks on the main menu link on this website on the top right hand of this website named Useful Information, that link then points to the URL shown below, the URL shown below then points at the script and tells the script what sub menu is requested. 

http://servertosite.com/sub.html?menu=information&c=26

A second isolated section in file

How to Properly Set Up this Script on Our Free Low Maintenance Web Friendly Website Package. To Make Sub Menus Show on a Separate Dedicated Page!

On the this website (servertosite.com) I made a spare PHP page with HTML in it to paste the script into, but removed echo $dne; from the very bottom of the script after I pasted it in (you will find out why you must do this, in the next paragraph). If using our Low Maintenance Web Friendly Website Package which is available on this site, simply copy and paste the above script (Clean Strip File Script Type 1) between the content start and content end HTML tags in either our two column template and rename the page to something like sub-menu.php or use something like the page-not-found.php as a template and rename it to something like sub-menu.php so you do not lose you your page-not-found.php page.

After you have pasted the  Clean Strip File script in minus echo $dne; from the bottom of the script, click your mouse out of the script and underneath its ending PHP tag ?>, and paste in the code shown below directly underneath the main Clean Strip File script on the same page:

The above script will output: Your selected sub menu items for entrees. If in we used entrees as our tag. So name your tags appropriately or remove <?php echo $ok; ?> out of your heading... Under the heading the sub menu page will show the user using your site, the sub menu items entrees in our made up example, so long as you have isolated the correct HTML for the menu items out of the header.txt file.

If you find that because you are using drop down menus when you isolate part of the sub menus you may be left with an unwanted </li> followed by a </ul> because you have only grabbed part of the menu, I ran into this issue on this website and solved it with the script below. I simply put the second isolating HTML comment tag above the </li> tag I did not want processed on the sub menu page and then added the closing </ul> tag that I did want via PHP as shown below. Of course the other sub menu items for other categories you isolate may not need this treatment, but because you have by using the script below added an extra closing </ul> tag onto the end of all sub menu results within the HTML, you will have to compensate for this by placing your closing isolating HTML comment tags above the closing </ul> on sub menu items that would other wise have been fine, so you do not get a double closing </ul> in your results.

Now we move on. Next you can go to the clds folder of the website package, open the header.txt file and start putting HTML comment tags around the list items in your sub menus <!-- entrees start--> like so <!-- entrees end --> . Makes sure the path for the target file in the script points to the header.txt file.

Now in the above paragraph I wrote entrees as one of our sub menus to be targeted, so to make the main parent menu link on your website for entrees bring up the sub menu items for entrees, you would make that link point at the file you pasted the script into followed by the string I mentioned earlier, so the script knows what part of the menu you want. For example the main link for entrees could link to the below:

yourwebsitesname.com/filewithscript.html?menu=entrees&c=28

In the above URL first comes your website name, then a question mark, then menu= followed by your targeted sub menu, then an & symbol, then c= followed by a number that will trim bits of unwanted HTML comment code from showing through, just change the number and refresh until it trims the unwanted code if working things out with maths is not your thing.

Well that is it regarding using the Clean Strip File Type 1 script with our Low Maintenance Web Friendly Website Package... The only other script on this project page suitable for making sub menus for our Low Maintenance Web Friendly Website project is the Clean Strip File Script Type 3 which is the script under the script below, that script would be ideal for a website that was only 'ever' going to have 'one' drop down menu but no more than one drop down menu on one of the main menu links (you could have multiple sub menus, but no more than one actual drop down menu from the top). Clean Strip File Script Type 3 would do exactly what you need for the job, no more no less, you would not even have to make any fancy URL's, you would just make a standard no fuss direct link to the page that holds the script, make sure you have HTML comments around the sub menu in the header.txt file (even empty HTML comments)  and everything should would work perfectly as it should.

Clean Strip File Script Type 2. A Version that Will Read Only a Certain Specified Character Count into File to Be Stripped. Useful for Larger Files to Be Stripped, to Stop Unnecessary Processing Time and Resources

The above script is for processing a specified character count into a file, which is set via URL. So for example I borrowed a URL from our last example that I had used with the previous script http://servertosite.com/sub.html?menu=information&c=26&s=1000 and you will notice I added s= followed by my desired character count into the file. I just put 1000, but on a large file you will probably be going a lot deeper than 1000 characters into your target file. Apart from that the script behaves exactly the same as the first script on this page.

Clean Strip File Script Type 3. A Version That is Only for Stripping One Specified Target Section from a Small File

The above script will strip one section out of a file, if you only have comment tags around the area you are isolating, you can get away with just referencing the start of the comment tag with no words, else if you have other unrelated comment tags in the script you will need to put the first word of your isolating comments after the opening of the comment tag in front of the tag variable in the PHP script. To get the script doing its thing, you just need to point a URL at the script and your desired isolated part will be displayed or processed.

You may also notice the numbers +19 and -1 in the above script. If you change the targeting tag from <! an opening HTML comment as shown above to something else, then you will probably need to change those numbers to compensate for the length of the new tag, so you get a clean strip without anything unwanted like parts of the new different type of targeting tag showing in your results.

Clean Strip File Script Type 4. A Version Made to Strip Information from between HTML Title Tags. Is Fine With Both Large and Small Files

If you wanted the title from between <title> title tags </title> out from HTML in a page. The above script will do that for you.

The tag variable in the above script has the correct string for the title page in it, $tag='title>' even though it may look like I left of the opening bracket, this is because the script will find the first and the last occurrence of the tag and there is only one title tag in a HTML file, the opening title tag and the closing title tag both end with title> so the script has found its target and will successfully return you the title from between its title tags.

Personally Recommended Services and Products Below

KnownHost Quality Managed VPS/Hybrid and Dedicated Servers Click Here

KnowHost is a truly respected VPS/Hybrid & Dedicated server provider. Advantages of VPS over shared hosting: Dedicated RAM, Useable Bandwidth, Unlimited Websites, Shell, More Control.