Werbung - Gast

Python


Keywords for this topic
environ, key, print, html, replace, escape, keys, class, import, css, head, def, title, type, python

Python

Unread postby Thomas » Wed 12. Aug 2009, 21:17

import sys
import os
import re

def print_environ(environ=os.environ):
"""Dump the shell environment as HTML."""
keys = environ.keys()
keys.sort()
i = 0
for key in keys:
if not re.search("^HTTP_|^REQUEST_", key):
continue
if i == 0:
print """<tr class="normal"><td>""", escape(key), "</td><td>", escape(environ[key]), "</td></tr>"
i = 1
else:
print """<tr class="alt"><td>""", escape(key), "</td><td>", escape(environ[key]), "</td></tr>"
i = 0

def escape(s, quote=None):
"""Replace special characters '&', '<' and '>' by SGML entities."""
s = s.replace("&", "&amp;") # Must be done first!
s = s.replace("<", "&lt;")
s = s.replace(">", "&gt;")
if quote:
s = s.replace('"', "&quot;")
return s


print """Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="../../css/style.css">
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0">
<tr class="subhead" align="Left"><th>Name</th><th>Value</th></tr>"""
print_environ()
print """</table>
</body>
</html>"""
Mfg Thomas
User avatar
Thomas
Administrator
Administrator
 
Users InformationUsers Information Users Information
 

Show post links

Offline

Werbung - Mitte

 

Share on ...

Share on FacebookShare on TwitterShare on TuentiShare on SonicoShare on FriendFeedShare on OrkutShare on DiggShare on MySpaceShare on DeliciousShare on Technorati

Werbung - Allgemein


Who is online

Users browsing this forum: No registered users and 1 guest

Return to Scriptbörse: Angebote

Who is online

Users browsing this forum: No registered users and 1 guest

cron

User Control Panel

Login

Who is online

In total there is 1 user online :: 0 registered, 0 hidden, 0 bots and 1 guest (based on users active over the past 60 minutes)
Most users ever online was 2918 on Sun 19. Jan 2020, 07:36

Users browsing this forum: No registered users and 1 guest
TWCportal DE | TWCmail DE & TWCmail EU | Help-Book DE & Help-Book EU | PHP-Wolf | Online-ABC & OnlineABC | Web-Hacks


Usemax-Advertisement | Zanox - Das Werbenetzwerk | TWCgames DE