Glype Proxy – Content Filtering

So again with the Glype Proxy, I needed to filter some content on all pages, so I had to write a little mod, it’s quick simple, and unreliable so yay!

To begin, Open up /includes/parser.php … and insert the following code (I put it around line 48):

// Dayjo - Filter Modification	  
// Open the filters file and filter all of the results. $filename = "filters.txt"; $fp = @fopen($filename, 'r'); if ($fp) { $array = explode("\n", fread($fp, filesize($filename))); foreach($array as $key => $val){ list($before,$after) = split("~",$val); $input = preg_replace($before,$after,$input); } }

Then, in the main Glype directory (/), create a text file called “filters.txt“.

Now, in this file you can provide text filters using regular expressions, separating with the tilde symbol ( ~ ), for instance, if you wanted to filter out swear words you would put the following into the file:

/shit/~****
/twat/~****

etc…

Somebody wished to modify page titles, so to do that you will need to something like:

/<title>(.+)</title>/~<title>$1 - PROXIFIED BY DAYJO</title>

Which would add ” – PROXIFIED BY DAYJO” to the original title. (Remove the $1 to get rid of the original title).

This modification could be used for a variety of reasons, removing images or ads, replacing content with your own, or making pages look funny by replacing the with teh… whatever takes your fancy.