DBhelp.closedb()
            DBhelp = None

        portarray = []
        if count > 0:
            validresult = True
            for temp in result:
                aport = ports.Port(
                    ip=temp['ip'],
                    port=temp['port'],
                    timesearch=temp['timesearch'],
                    state=temp['state'],
                    name=temp['name'],
                    product=temp['product'],
                    version=temp['version'],
                    script=SQLTool.decodestring(temp['script']),
                    detail=SQLTool.decodestring(temp['detail']),
                    head=SQLTool.decodestring(temp['head']),
                    city=temp['city'],
                    hackinfo=SQLTool.decodestring(temp['hackinfo']),
                    disclosure=SQLTool.decodestring(temp['disclosure']))

                #                 aport=ports.Port(ip=temp[0],port=temp[1],timesearch=temp[2],state=temp[3],name=temp[4],product=temp[5],version=temp[6],script=temp[7])
                portarray.append(aport)
        print str(count) + '          ' + str(pagecount)
        return portarray, count, pagecount
    return [], 0, pagecount


def portshow(ip='',
             port='',
            result,content,count,col=DBhelp.searchtableinfo_byparams([table+' left join ip_maindata on snifferdata.ip=ip_maindata.ip'], [table+'.'+'ip','port','timesearch',table+'.'+'state','name','product','version','script','detail','head','city','hackinfo','disclosure'], request_params, values_params,limit=limit,order=table+'.'+'port',extra=extra,command=command)
        except Exception,e:
            print str(e)+'portcontrol 69'
            if DBhelp is not None:
                DBhelp.closedb()
            return [],0,0
        if DBhelp is not None:
                DBhelp.closedb()
                DBhelp=None
            

        portarray=[]
        if count>0:
            validresult=True
            for temp in result :
                aport=ports.Port(ip=temp['ip'],port=temp['port'],timesearch=temp['timesearch'],state=temp['state'],name=temp['name'],product=temp['product'],version=temp['version'],script=SQLTool.decodestring(temp['script']),detail=SQLTool.decodestring(temp['detail']),head=SQLTool.decodestring(temp['head']),city=temp['city'],hackinfo=SQLTool.decodestring(temp['hackinfo']),disclosure=SQLTool.decodestring(temp['disclosure']))

#                 aport=ports.Port(ip=temp[0],port=temp[1],timesearch=temp[2],state=temp[3],name=temp[4],product=temp[5],version=temp[6],script=temp[7])
                portarray.append(aport)
        print str(count)+'          '+str(pagecount)
        return portarray,count,pagecount
    return [],0,pagecount
def portshow(ip='',port='',timesearch='',state='',name='',product='',version='',script='',detail='',page='0',extra='',command='and',head='',city=''):
    validresult=False
    request_params=[]
    values_params=[]
    if ip!='':
        request_params.append('ip')
        values_params.append(SQLTool.formatstring(ip))
    if port!='':
        request_params.append('port')