One Hat Cyber Team
  • Dir : ~/lib64/python2.7/Demo/cgi/
  • Edit File: wiki.py
    ' print s % self.data print '' print '' % self.name print '
    ' print '' % label print "
    " def cmd_create(self, form): self.data = form.getvalue("text", "").strip() error = self.store() if error: print "

    I'm sorry. That didn't work

    " print "

    An error occurred while attempting to write the file:" print "

    ", escape(error) else: # Use a redirect directive, to avoid "reload page" problems print "" s = '' print s % (self.scripturl + "?cmd=view&page=" + self.name) print "" print "

    OK

    " print "

    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 '%s' % (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)