Server IP : 103.119.228.120 / Your IP : 18.117.103.185 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/ssl/local/ssl/local/ssl/lib64/python2.7/Demo/cgi/ |
Upload File : |
"""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)