dowski's projects - phpfilter

phpfilter

They said it couldn't be done ... they said it shouldn't be done ... some even laughed ... behold, the PHPFilter.

Created: 2006-02-13 | Updated: 2006-02-16 | Status: Complete | Tags: cherrypy python filter

Why waste time writing buggy PHP code to begin with? Cut to the chase with the PHPFilter for CherryPy. Take off those rose colored glasses and experience; All errors, all the time.

import random

import cherrypy
from cherrypy.lib.filter.basefilter import BaseFilter

class PHPFilter(BaseFilter):
    def __init__(self, dir_root):
        self.dir_root = dir_root

    def beforeMain(self):
        if cherrypy.request.path.endswith('.php'):
            line = random.randint(1,300)
            cherrypy.response.body = """<br />
            <b>Parse error</b>: parse error in <b>%s%s</b> on line <b>%s</b><br />
            """ % (self.dir_root, cherrypy.request.path, line)


if __name__ == '__main__':
    class Test:
        _cpFilterList = [PHPFilter('/var/www/mysite')]

    cherrypy.config.update({'logDebugInfoFilter.on':False})
    cherrypy.root = Test()
    cherrypy.server.start()

Files:

phpfilter.py [colorized]


Comments:

john speno
2005-10-21
this is the funniest thing since you showed us your first can-tenna.

Robert
2005-10-28
You obviously were abused as a child by PHP or someone resembling PHP, and are acting out to try to come to terms with your trauma. I suggest therapy. Deep, expensive therapy.

me
2005-11-10
:-)))))))))

James
2006-01-16
Funny stuff... Best CP filter ever!

Add Comment:

Commenting disabled because of spam problem...

Menu:

Home
Admin

Projects:

balloondemo
brockman
buffet
buffetmyghty
buffetstring
buffetxslt
cardinfo
cp22collection
cp22simple_ajax
cp_middleware_server
cpmyghty
excuses
iresponse
littlebrother
multiauth
phpfilter
pysourcecolorfilter
request2
simplebackend
stunnelfilter
wsgi_filter

Tags:

wireless
wsgi
http
templating
cherrypy
ssl
python
plugins
module
win32
application
ajax
library
cheetah
myghty
filter
kid

Powered By: