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	  <br>
// 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 =&gt; $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:

/&lt;title&gt;(.+)&lt;/title&gt;/~&lt;title&gt;&#36;1 - PROXIFIED BY DAYJO&lt;/title&gt;

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.

7 thoughts on “Glype Proxy – Content Filtering

  1. This post is great! The ‘explode(“n”, ‘ gave me some troubles but you provided a very good start. Shouldn’t it be ‘explode(“\n”‘?
    Cheers, Fred.

  2. Love your function. Got a few things to add that I found much more beneficial.
    Firstly, for case-insensitive replacement simple add “i” in the filters list.
    Eg.
    /shit/i~****
    /twat/i~****
    /myspace/i~****

    Secondly I’d recommend putting the function at around lines 105 (just after ” // Replace input with the updated document
    $input = $new;”))
    This simply censors the keywords closer towards the final output (I haven’t fully gone through it yet) which fixed the problem of some urls getting censored causing glype to be unable to continue.

    Lastly, Thank you very much for this useful function. I greatly appreciate it.

    • Thanks :) yeah probably is a better place to put it! The ‘i’ addition is a handy hint for those not too familiar with regular expressions.

  3. Hi all,

    can u give me an idea on how to make this content filtering a dynamic one i.e. it checks from a range of words in a sentence before deciding to filter out the predetermined text filters.

Leave a Reply