Beispiel #1
0
def modifyProject(pid,project,other):
	result = db.query("SELECT pid FROM project WHERE project = '%s' AND pid != '%s'" % (project,pid))
	if result:
		return False
	else:
		db.update("project", where='pid=$pid', vars={'pid': pid}, project=project ,other=other)
		return True
Beispiel #2
0
def modifyCity(cid, city, other):
	result = db.query("SELECT cid FROM city WHERE city = '%s' AND cid != '%s'" % (city, cid))
	if result:
		return False	
	else:
		db.update("city", where='cid=$cid', vars={'cid': cid}, city=city, other=other)
		return True
Beispiel #3
0
def modifyIDC(iid,idcname,city,contact,hztime,other):
	result = db.query("SELECT iid FROM idc WHERE idcname = '%s' AND iid != '%s'" % (idcname, iid))
	if result:
		return False
	else:
		db.update("idc", where='iid=$iid', vars={'iid': iid}, idcname=idcname, city=city, contact=contact, hztime=hztime,other=other)
		return True
Beispiel #4
0
def modifyProject(pid,project,other):
	result = db.query("SELECT pid FROM project WHERE project = '%s' AND pid != '%s'" % (project,pid))
	if result:
		return False
	else:
		db.update("project", where='pid=$pid', vars={'pid': pid}, project=project ,other=other)
		return True
Beispiel #5
0
def modifyHost(hid,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,modifytime,modifyman):
	result = db.query("SELECT hid FROM hosts WHERE hostname = '%s' AND hid != '%s'" % (hostname, hid))
	if result:
		return False
	else:
		db.update("hosts", where='hid=$hid', vars={'hid':hid}, 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,modifytime=modifytime,modifyman=modifyman)
		return True
Beispiel #6
0
def modifyIDC(iid,idcname,city,contact,hztime,other):
	result = db.query("SELECT iid FROM idc WHERE idcname = '%s' AND iid != '%s'" % (idcname, iid))
	if result:
		return False
	else:
		db.update("idc", where='iid=$iid', vars={'iid': iid}, idcname=idcname, city=city, contact=contact, hztime=hztime,other=other)
		return True
Beispiel #7
0
def modifyCity(cid, city, other):
	result = db.query("SELECT cid FROM city WHERE city = '%s' AND cid != '%s'" % (city, cid))
	if result:
		return False	
	else:
		db.update("city", where='cid=$cid', vars={'cid': cid}, city=city, other=other)
		return True
Beispiel #8
0
def modifyHost(hid,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,modifytime,modifyman):
	result = db.query("SELECT hid FROM hosts WHERE hostname = '%s' AND hid != '%s'" % (hostname, hid))
	if result:
		return False
	else:
		db.update("hosts", where='hid=$hid', vars={'hid':hid}, 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,modifytime=modifytime,modifyman=modifyman)
		return True
Beispiel #9
0
def modifyApply(aid,sitename,idc,project,addr_ip,sofeware,datadir,startscrite,port,mysql_conf,mysql_ip,mysql_stype,mysql_name,mysql_use,mysql_pw,dev_name,other,modifytime,modifyman):
	if addr_ip != '':
		result = db.query("SELECT aid FROM applications WHERE sitename = '%s' AND addr_ip = '%s'" % (sitename,addr_ip))
		if result:
			return False
	db.update("applications", where='aid=$aid', vars={'aid':aid}, 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,modifytime=modifytime,modifyman=modifyman)
	return True
Beispiel #10
0
 def GET(self,aid,cid):
     if isadmin():
         try:
             db.delete(commt,where="id ="+cid)
             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()
     else:
         return render.error()
Beispiel #11
0
 def POST(self,aid):
     if not isadmin():
         return render.error()
     try:
         data =web.input()
         text = data.content
         atitle = data.title
         if not len(db.select(script))==0:
             db.delete(script)
         db.update(artt,where="id="+aid,title=atitle,content=text)
         raise web.seeother('/')
     except:
         return render.error()
Beispiel #12
0
def UpdateUserInfo(user, phone, email, other):
    return db.update("users",
                     where='username=$user',
                     vars={'user': user},
                     phone=phone,
                     email=email,
                     other=other)
Beispiel #13
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()
Beispiel #14
0
def UpdateUserPrivilege(user, privilege):
    return db.update("users",
                     where='username=$user',
                     vars={'user': user},
                     privilege=privilege)
Beispiel #15
0
from config.setting import db

pieces = piece.get_all()
for p in pieces:
    data = piece.parse_content(p.content)

    author_name = data["author"]
    work_title = data["work"]

    if p["author"]:
        data["author"] = p["author"]
    elif data["author"]:
        # return author_id
        data["author"] = author.add(author_name)

    if p["work"]:
        data["work"] = p["work"]
    elif data["work"]:
        # return work_id
        data["work"] = work.add(work_title)

    # if author_name or work_title:
    #     # print p.content
    #     print "origin:\t\t" + p.content
    #     print "content:\t" + data["content"]
    #     print "author:\t\t" + (author_name and author_name or "None")
    #     print "work:\t\t" + (work_title and work_title or "None")
    #     print ""

    db.update("piece", where="id=$id", vars=p, **data)
Beispiel #16
0
def UpdateUserPrivilege(user,privilege):
	return db.update("users", where='username=$user', vars={'user':user}, privilege=privilege)
from model import piece
from model import work
from model import author
from config.setting import db

pieces = piece.get_all()
for p in pieces:
    data = piece.parse_content(p.content)
    print data
    author_name = data["author"]
    work_title = data["work"]

    if p["author"]:
        data["author"] = p["author"]
    elif data["author"]:
        # return author_id
        data["author"] = author.add(author_name)
    
    if p["work"]:
        data["work"] = p["work"]
    elif data["work"]:
        # return work_id
        data["work"] = work.add(work_title)

    db.update("piece",where="id=$id",vars=p,**data)
Beispiel #18
0
def UpdateUserInfo(user,phone,email,other):
	return db.update("users", where='username=$user', vars={'user':user}, phone=phone, email=email, other=other)