defendConnection(self): if os.path.exists(self.directory): rmtree(self.directory)
defunknown(self, cmd): return"Unknown Command! Type 'help' or '?' to get help!"
defhelpmenu(self, cmd): if len(cmd) < 2: return" Available commands: ?, help, create, show, compile.\n Type 'help COMMAND' to get information about the specific command." if (cmd[1] == "create"): return (" Create a file. Syntax: create TYPE NAME\n" " TYPE: type of the file. Possible types are log, tex, sty, mp, bib\n" " NAME: name of the file (without type ending)\n" " The created file will have the name NAME.TYPE") elif (cmd[1] == "show"): return (" Shows the content of a file. Syntax: show TYPE NAME\n" " TYPE: type of the file. Possible types are log, tex, sty, mp, bib\n" " NAME: name of the file (without type ending)") elif (cmd[1] == "compile"): return (" Compiles a tex file with the help of pdflatex. Syntax: compile NAME\n" " NAME: name of the file (without type ending)")
defshow(self, cmd): if len(cmd) < 3: return" Invalid number of parameters. Type 'help show' to get more info." ifnot cmd[1] in ["log", "tex", "sty", "mp", "bib"]: return" Invalid file ending. Only log, tex, sty and mp allowed"
if full_filename.startswith(self.directory) and os.path.exists(full_filename): with open(full_filename, "r") as file: content = file.read() else: content = "File not found." return content
defflag(self, cmd): pass
defcreate(self, cmd): if len(cmd) < 3: return" Invalid number of parameters. Type 'help create' to get more info." ifnot cmd[1] in ["log", "tex", "sty", "mp", "bib"]: return" Invalid file ending. Only log, tex, sty and mp allowed"
with open(full_filename, "w") as file: print "File created. Type the content now and finish it by sending a line containing only '\q'." while1: text = raw_input(""); if text.strip("\n") == "\q": break write_to_file = True; for filter_item in ("..", "*", "/", "\\x"): if filter_item intext: write_to_file = False break if (write_to_file): file.write(text + "\n") return"Written to " + filename + "."
defcompilePDF(self, cmd): if (len(cmd) < 2): return" Invalid number of parameters. Type 'help compile' to get more info." filename = cmd[1] + ".tex" full_filename = os.path.join(self.directory, filename) full_filename = os.path.abspath(full_filename)
print full_filename ifnot full_filename.startswith(self.directory) ornot os.path.exists(full_filename): return"Could not compile file."
if (isset($_POST["pic"]) && $_POST["pic"] != "" && !is_admin()) { $pic = get_contents($_POST["pic"]); if (!is_image($pic)) { die("<p><h3 style=color:red>Does this look like an image to you???????? people are dumb these days...</h3></p>" . htmlspecialchars($pic)); } else { $pic_name = "profiles/" . sha1(rand()); file_put_contents($pic_name, $pic); } }