-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddsite.py
executable file
·47 lines (39 loc) · 1.57 KB
/
addsite.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python
# Copyright (C) 2011 Bolin Huang <[email protected]>
# I made it just for fun -_-". And I hope it works as desired.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
import sys,os
from ftplib import FTP
import cgi
class Addsite:
def getsite(self):
try:
form=cgi.FieldStorage()
item=":".join([form["site"].value,form["user"].value,form["passwd"].value])+":\n";
open("new_address","a").write(item)
except:
print "An error occur"
def puthead(self):
print "Content-Type: text/html; charset=GBK\r\n\r\n"
print "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=GBK\">\r\n"
print "<TITLE>%s</TITLE></head>\n"%"Simple FTP Search Engine"
print """
<H1>Simple Ftp Search Engine</H1>
<form action="/cgi-bin/search">
<input type="text" name="q"/>
<input type="submit" />
</form> """
print "<hr/>"
add=Addsite()
add.puthead()
add.getsite()
print "<h3>Submit success. </br>Thanks.</h3>\r\n"