Esempio n. 1
0
def insert_idc(idcname,city, contact,hztime, other):
	result = db.query("SELECT iid FROM `idc` WHERE idcname='%s'" % (idcname))
	if result:
		return False
	else:
		db.insert('idc', idcname=idcname, city=city, contact=contact,hztime=hztime, other=other)
		return True
Esempio n. 2
0
def insert_city(city, other):
	result = db.query("SELECT cid FROM `city` WHERE city='%s'" % (city))	
	if result:
		return False
	else:
		db.insert('city', city=city, other=other)
		return True
Esempio n. 3
0
def insert_project(project, other):
	result = db.query("SELECT pid FROM `project` WHERE project='%s'" % (project))
	if result:
		return False
	else:	
		db.insert('project', project=project, other=other)
		return True
Esempio n. 4
0
def insert_idc(idcname,city, contact,hztime, other):
	result = db.query("SELECT iid FROM `idc` WHERE idcname='%s'" % (idcname))
	if result:
		return False
	else:
		db.insert('idc', idcname=idcname, city=city, contact=contact,hztime=hztime, other=other)
		return True
Esempio n. 5
0
def insert_project(project, other):
	result = db.query("SELECT pid FROM `project` WHERE project='%s'" % (project))
	if result:
		return False
	else:	
		db.insert('project', project=project, other=other)
		return True
Esempio n. 6
0
def insert_city(city, other):
    result = db.query("SELECT cid FROM `city` WHERE city='%s'" % (city))
    if result:
        return False
    else:
        db.insert('city', city=city, other=other)
        return True
Esempio n. 7
0
 def POST(self):
     i=web.input()
     name=i['name']
     content=i['content']
     if name=='' :
         db.insert('message',content=content,post_time=datetime.now())
     else :
         db.insert('message',name=name,content=content,post_time=datetime.now())
     return web.seeother('/message')
Esempio n. 8
0
def insert_apply(sitename,idc,project,addr_ip,sofeware,datadir,startscrite,port,mysql_conf,mysql_ip,mysql_stype,mysql_name,mysql_use,mysql_pw,dev_name,other,jointime,modifytime,modifyman):

	# Check the ip address exists?
	if addr_ip != '':
		result = db.query("SELECT aid FROM `applications` WHERE addr_ip='%s' AND sitename='%s'"  % (addr_ip,sitename))
		if result:
			return False

	# If not enter the ip address, also saved to database.
	db.insert('applications',sitename=sitename,idc=idc,project=project,addr_ip=addr_ip,sofeware=sofeware,datadir=datadir,startscrite=startscrite,port=port,mysql_conf=mysql_conf,mysql_ip=mysql_ip,mysql_stype=mysql_stype,mysql_name=mysql_name,mysql_use=mysql_use,mysql_pw=mysql_pw,dev_name=dev_name,other=other,jointime=jointime,modifytime=modifytime,modifyman=modifyman)
	return True
Esempio n. 9
0
def insert_user(privilege, username, password, createtime, lastlogin, loginip,
                phone, email, other):
    db.insert('users',
              privilege=privilege,
              username=username,
              password=password,
              createtime=createtime,
              lastlogin=lastlogin,
              loginip=loginip,
              phone=phone,
              email=email,
              other=other)
Esempio n. 10
0
 def POST(self):
     if not isadmin():
         return render.error()
     try:
         data =web.input()
         text = data.content
         atitle = data.title
     
         db.insert(artt,id=0,date=web.SQLLiteral("NOW()"),usrid=session.id,comment=0,title=atitle,content=text)
         raise web.seeother('/')
     except:
         return render.error()
Esempio n. 11
0
 def POST(self):
     i=web.input()
     name=i['name']
     pwd1=i['pwd1']
     pwd2=i['pwd2']
     ident = db.query("select * from user where name='%s'" %(name))
     if ident :
         return "<html><body><p>用用户已存在!</p><a href='/login'>返回登录页面</a></body></html>"
     else :
         if pwd1==pwd2 :
             db.insert('user',name=name,pwd=pwd1,post_time=datetime.now())
             return "<html><body><p>注册成功!</p><a href='/login'>返回登录页面</a></body></html>"
         else :
             return "<html><body><p>注册失败!两次密码输入不一致!</p><a href='/register'>返回注册页面</a></body></html>"
Esempio n. 12
0
 def POST(self):
     #you can add user only on the first time
     if int(db.query("select count(*) from "+usert)[0]["count(*)"])!=0:
         return render.error()
     postdata = web.input()
     usrid    = postdata.get("usrname","")
     pw       = postdata.get("password","")
     pw+=salt
     pwmd5 = md5.new(pw).hexdigest()
     db.insert(usert,id=1,user=usrid,password=pwmd5);
     seed = random.randint(0,100000)
     session.hash = md5.new((usrid+pwmd5+str(seed))).hexdigest()
     session.id   = 1
     session.seed = seed
     raise web.seeother('/')
Esempio n. 13
0
def insert_host(hostname,city,project,idc,port,addr1_ip,addr1_netmask,addr1_gateway,addr1_line,addr2_ip,addr2_netmask,addr2_gateway,addr2_line,addr3_ip,addr3_netmask,addr3_gateway,addr3_line,memory,cpu,disk,buytime,servicetime,hardwareinfo,bandwidth,uses,status,company,os,other,jointime,modifytime,modifyman):

	# Check the ip address exists?
	if addr1_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr1_ip, addr1_ip, addr1_ip))
		if result:
			return False
	if addr2_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr2_ip, addr2_ip, addr2_ip))
		if result:
			return False
	if addr3_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr3_ip, addr3_ip, addr3_ip))
		if result:
			return False

	# If not enter the ip address, also saved to database.
	db.insert('hosts',hostname=hostname,city=city,project=project,idc=idc,port=port,addr1_ip=addr1_ip,addr1_netmask=addr1_netmask,addr1_gateway=addr1_gateway,addr1_line=addr1_line,addr2_ip=addr2_ip,addr2_netmask=addr2_netmask,addr2_gateway=addr2_gateway,addr2_line=addr2_line,addr3_ip=addr3_ip,addr3_netmask=addr3_netmask,addr3_gateway=addr3_gateway,addr3_line=addr3_line,memory=memory,cpu=cpu,disk=disk,buytime=buytime,servicetime=servicetime,hardwareinfo=hardwareinfo,bandwidth=bandwidth,uses=uses,status=status,company=company,os=os,other=other,jointime=jointime,modifytime=modifytime,modifyman=modifyman)
	return True
Esempio n. 14
0
def insert_host(hostname,city,project,idc,port,addr1_ip,addr1_netmask,addr1_gateway,addr1_line,addr2_ip,addr2_netmask,addr2_gateway,addr2_line,addr3_ip,addr3_netmask,addr3_gateway,addr3_line,memory,cpu,disk,buytime,servicetime,hardwareinfo,bandwidth,uses,status,company,os,other,jointime,modifytime,modifyman):

	# Check the ip address exists?
	if addr1_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr1_ip, addr1_ip, addr1_ip))
		if result:
			return False
	if addr2_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr2_ip, addr2_ip, addr2_ip))
		if result:
			return False
	if addr3_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr3_ip, addr3_ip, addr3_ip))
		if result:
			return False

	# If not enter the ip address, also saved to database.
	db.insert('hosts',hostname=hostname,city=city,project=project,idc=idc,port=port,addr1_ip=addr1_ip,addr1_netmask=addr1_netmask,addr1_gateway=addr1_gateway,addr1_line=addr1_line,addr2_ip=addr2_ip,addr2_netmask=addr2_netmask,addr2_gateway=addr2_gateway,addr2_line=addr2_line,addr3_ip=addr3_ip,addr3_netmask=addr3_netmask,addr3_gateway=addr3_gateway,addr3_line=addr3_line,memory=memory,cpu=cpu,disk=disk,buytime=buytime,servicetime=servicetime,hardwareinfo=hardwareinfo,bandwidth=bandwidth,uses=uses,status=status,company=company,os=os,other=other,jointime=jointime,modifytime=modifytime,modifyman=modifyman)
	return True
Esempio n. 15
0
 def POST(self):
     try:
         con = web.input()
         if isadmin():
             id=session.id
             user=db.select(usert,where=("id="+str(id)))[0].user
             hp='/'
             mail="none"
         else:
             mail=con.get('email','none')
             user=con.get('author','none')
             hp  =con.get('hp','')
             if hp.find("http://")!=0:
                 hp = "http://"+hp
             id=0
         data =con.get('comment','none')
         db.insert(msg,author=user,email=mail,content=web.websafe(data),id=0,homepage=hp,date=web.SQLLiteral("NOW()"),usrid=id)
         raise web.seeother('/about')
     except:
         return render.error()
Esempio n. 16
0
 def POST(self,aid):
     try:
         articleid = int(aid)
         con = web.input()
         if isadmin():
             id=session.id
             user=db.select(usert,where=("id="+str(id)))[0].user
             mail="none"
             hp='/'
         else:
             mail=con.get('email','none')
             user=con.get('author','none')
             hp  =con.get('hp','')
             if hp.find("http://")!=0:
                 hp = "http://"+hp
             id=0
         data =con.get('comment','none')
         db.insert(commt,author=user,email=mail,content=web.websafe(data),id=0,articleid=articleid,homepage=hp,date=web.SQLLiteral("NOW()"),usrid=id)
         count=int(db.select(artt,what="comment",where=("id = "+aid))[0]["comment"])+1
         db.update(artt,where=("id = "+aid),comment=count)
         raise web.seeother('/article/'+aid)
     except:
         return render.error()
Esempio n. 17
0
def add(name):
    id = has(name)
    if id:
        return id
    else:
        return db.insert("author",name=name) 
Esempio n. 18
0
def add(title):
    id = has(title)
    if id:
        return id
    else:
        return db.insert("work", title=title)
Esempio n. 19
0
def insert_user(privilege,username,password,createtime,lastlogin,loginip,phone,email,other):
	db.insert('users',privilege=privilege,username=username,password=password,createtime=createtime,lastlogin=lastlogin,loginip=loginip,phone=phone,email=email,other=other)
Esempio n. 20
0
def insertServerInfo(hostname,ip1,ip2,project,hostconfig,idc):
	db.insert('servers',hostname=hostname,ip1=ip1,ip2=ip2,project=project,hostconfig=hostconfig,idc=idc)
Esempio n. 21
0
def addHistory(content,description,delman,deltime):
	db.insert('history',content=content,description=description,delman=delman,deltime=deltime)
Esempio n. 22
0
def add(title):
    id = has(title)
    if id:
        return id
    else:
        return db.insert("work",title=title) 
Esempio n. 23
0
def addHistory(content, description, delman, deltime):
    db.insert('history',
              content=content,
              description=description,
              delman=delman,
              deltime=deltime)