Beispiel #1
0
    def POST(self):
        color='red'
        try:
            user=web.input().user
            passwd=md5str(web.input().passwd)
            if cmp(web.session.Session.yzm.upper(),web.input().yzm.upper()):
                f='请输入正确的验证码'
                color='red'
                return render.login(f,color,imgs=authidentcode(),b=web.session.Session.yzm)
            else:
                pass


            if checkpass(user,passwd):

                web.session.Session.user=user
                web.session.Session.uuid=md5str(user+config.mi_key)
                session_add('client_ip','0.0.0.0')
                session_add('user_info','')
                web.session.Session.user_info=user_persion_info(web.session.Session.user).list()[0]
                web.session.Session.client_ip=web.ctx.env.get('REMOTE_ADDR')
                n_time=str(nowtime())
                login_logs(user,n_time,web.session.Session.client_ip)
                session_add('login_time','')
                web.session.Session.login_time=n_time

                web.redirect('/admin/manager/')

            else:
                f='验证失败!请输入正确的用户名和密码'
                return render.login(f,color,imgs=authidentcode(),b=web.session.Session.yzm)
        except:
                f='验证失败!请开启浏览器的cookies'
                return render.login(f,color,imgs=authidentcode(),b=web.session.Session.yzm)
Beispiel #2
0
    def POST(self):
        user=web.input().user
        passwd=md5str(web.input().passwd)

        if cmp(web.session.Session.yzm.upper(),web.input().yzm.upper()):
            f='Wrong! auth code is wrong!'
            color='red'
            return render.login(f,color,imgs=authidentcode(),b=web.session.Session.yzm)
        else:
            pass


        if checkpass(user,passwd):

            web.session.Session.user=user
            web.session.Session.uuid=md5str(user+config.mi_key)
            session_add('client_ip','0.0.0.0')
            session_add('user_info','')
            web.session.Session.user_info=user_persion_info(web.session.Session.user).list()[0]
            web.session.Session.client_ip=web.ctx.env.get('REMOTE_ADDR')
            n_time=str(nowtime())
            login_logs(user,n_time,web.session.Session.client_ip)
            session_add('login_time','')
            web.session.Session.login_time=n_time

            web.redirect('/admin/manager/')

        else:
            f='Fail,username or passwd wrong!'
            color='red'
            return render.login(f,color,imgs=authidentcode(),b=web.session.Session.yzm)
def host_port_jk(ip, port, id):
    import socket

    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.connect((ip, port))
        sock.close()
        sql = "update jk_host set jk_status='正常-port%s',jk_color='green',last_check='%s' where id='%s'" % (
            port,
            nowtime(),
            id,
        )
        config.dbw.query(sql)
        return sql
    except:
        sql = "update jk_host set jk_status='port连接失败-%s',jk_color='red',last_check='%s' where id='%s'" % (
            port,
            nowtime(),
            id,
        )
        config.dbw.query(sql)
        return sql
def m_host_edit_2(ip,type,hostinfo,id):
    t_time=nowtime()
    ip=ip
    type=type
    id=id
    sql="update jk_host set ip='%s',host_info='%s',jk_type='%s' where id=%s" % (ip,hostinfo,type,int(id))
    if config.dbw.query(sql):
        if type=='ping':
            host_ping(ip,id)
        else:
            host_port_jk(ip,int(type),id)
        return "主机修改成功!"
    else:
        return "主机未做修改"
def m_add_host(ip,type,hostinfo):
    t_time=nowtime()
    ip=ip
    type=type
    sql="insert into jk_host(ip,host_info,add_time,en_time,jk_status,jk_type) values('"+ip+"','"+hostinfo+"','"+t_time+"','"+t_time+"','Y','"+type+"')"
    sql2="select id,ip,jk_type from jk_host where jk_bz='Y'  order by add_time desc limit 1;"

    if config.dbw.query(sql):
        nowres=config.dbw.query(sql2).list()
        if type=='ping':
            host_ping(ip,nowres[0]['id'])
        else:
             host_port_jk(ip,int(type),nowres[0]['id'])
        return "主机添加成功!"
    else:
        return "主机添加失败!请重新添加"
Beispiel #6
0
        def POST(self):
            from app.models.madmin import authidentcode
            web.header("Content-Type","text/html; charset=utf-8;")
            if cmp(web.session.Session.yzm.upper(),web.input().yzm.upper()):
                return "<script type='text/javascript'>alert('验证码错误,请重新输入');window.location='"+web.input().atc_url+"';</script>"
            else:
                pass

            if not web.input().lyname:

                return "<script type='text/javascript'>alert('姓名是必填项,请输入您的名字');window.location='"+web.input().atc_url+"';</script>"
            elif not web.input().lyemail :

                return "<script type='text/javascript'>alert('邮箱是必填项,请输入您的邮箱地址');window.location='"+web.input().atc_url+"';</script>"
            elif not web.input().lytext:

                return "<script type='text/javascript'>alert('评论内容不能为空');window.location='"+web.input().atc_url+"';</script>"
            else:
                pass

            if  name_ck(web.input().lyname):
                pass
            else:

                return "<script type='text/javascript'>alert('请正确输入您的名字:格式为字母+数字,并且大于3位');window.location='"+web.input().atc_url+"';</script>"


            if  mail_ck(web.input().lyemail):
                pass
            else:
                return "<script type='text/javascript'>alert('请正确输入您的邮箱');window.location='"+web.input().atc_url+"';</script>"

            sql="insert into ly_tb(atc_id,mes_author,email,mes_text,date) value('"+web.input().atc_id+"','"+web.input().lyname+"','"+web.input().lyemail+"','"+string_to_mysqlstr(web.input().lytext)+"','"+nowtime()+"');"
            config.dbw.query(sql)


            return "<script type='text/javascript'>alert('评论成功!');window.location='"+web.input().atc_url+"';</script>"
Beispiel #7
0
def url_link_addone(title,site_url):
    sql="insert into link_url(title,site_url,date) values('"+web.input().title+"','"+web.input().site_url+"','"+nowtime()+"');"
    return config.dbw.query(sql)
def host_ping(ip,id):
    import platform
    if 'ndows' in platform.system():
        pingres = os.popen("ping -n 1 " + ip)
    else:
        pingres = os.popen("ping -c 1 " + ip)
    #print pingres
    status_text=''
    aliveInfo = re.compile("ms")
    for line in pingres:
        status_text+=line
    if re.findall(aliveInfo, status_text):
        sql="update jk_host set jk_status='正常ping',jk_color='green',last_check='%s' where id='%s'" % (nowtime(),id)
        config.dbw.query(sql)
    else:
        sql="update jk_host set jk_status='ping失败',jk_color='red',last_check='%s' where id='%s'" % (nowtime(),id)
        config.dbw.query(sql)
Beispiel #9
0
def add_moods(user,context):

    sql="insert into moods(mood_title,push_date,mood_author) values('"+string_to_mysqlstr(context)+"','"+nowtime()+"','"+user+"')"
    return config.dbw.query(sql)
Beispiel #10
0
    def POST(self):
        authuser()
        a=web.input().atc_title+"<br>"+web.input().atc_type+"<br>"+web.input().area_atc

        if not web.input().atc_title:
            return render.menu('',context='文章标题不能为空')
        else:
            title=web.input().atc_title
        if not web.input().area_atc:
            return render.menu('',context='文章内容不能为空')
        else:
            text=web.input().area_atc
        if not web.input().atc_type:
            return render.menu('',context='发表文章之前,请先添加文章分类')
        else:
            atc_fl=web.input().atc_type

        sql="insert into article(atc_title,atc_contents,atc_author,push_date,class_id) values('"+string_to_mysqlstr(title)+"','"+string_to_mysqlstr(text)+"','"+web.session.Session.user+"','"+nowtime()+"','"+str(atc_fl)+"')"
        if config.dbw.query(sql):
            res='发表成功'
        else:
            res='发表失败'

        return render.menu('',context=res)