#!/usr/bin/python from cgilib import * cgitb.enable() from pygments import highlight from pygments.lexers import PythonLexer from pygments.formatters import HtmlFormatter vars = cgi.FieldStorage() root = os.path.dirname(os.getcwd()) file = os.path.abspath(root + os.sep + vars.getvalue('file')) try: ip = cgi.escape(os.environ["REMOTE_ADDR"]) except: ip = 'IP_NUM' print 'Content-Type: text/html' print print print '' print '' print ' %s ' % (os.path.basename(file),) print ''' ''' print '' print '' #print '' #print '' #print '' #print '' #print '' #print '' print '' #print '' #print '' if os.path.isfile(file): print '
' print '' % (file,) print '' print ' %s ' % (os.path.basename(file),) print '
' # print '
' print '

' #print '

'
print '
'

#debug_cgi(vars)
if os.path.isfile(file):
    send_file_escaped(file)
else:
    msg  = "Connection from %s: %s not found or not a regular file: permission denied\n" % (ip,os.path.basename(file))
    #msg += "Connection to address %s will be permannently denied after 10 attempts to access private files\n" % (ip,)
    print cgi.escape(msg,True)

print '
' print '\n' print ''