Exemple #1
0
def index_origin():
    db = init_db()
    cursor = db.cursor()
    cursor.execute('''select * from feedback order by id DESC''')
    ret = cursor.fetchall()
    ret_list = []
    for _ in ret:
        try:
            ret_list.append([
                _[1].decode('utf-8'), _[2].decode('utf-8', ''),
                _[3].decode('utf-8', '')
            ])
        except Exception as e:
            print str(e)
            import traceback, sys
            traceback.print_exc(file=sys.stdout)
            #ret_list = [ ['error', 'error', 'error'] ]
    #try:
    #  ret_list = [ [ _[1].encode('utf-8', '') , _[2].encode('utf-8', ''), _[3].encode('utf-8', '') ] for _ in ret ]
    #except Exception as e:
    #  print str(e)
    #  import traceback, sys
    #  traceback.print_exc(file=sys.stdout)
    #  ret_list = [ ['error', 'error', 'error'] ]

    return render_template('index.html', comments=ret_list)
Exemple #2
0
def index():
    db = init_db()
    cursor = db.cursor()
    cursor.execute('''select * from feedback''')
    ret = cursor.fetchall()
    try:ret_list = [ [ _[1] , _[2], _[3] ] for _ in ret ]
    except:ret_list = [ ['error', 'error', 'error'] ]

    return render_template('index.html', comments = ret_list)
Exemple #3
0
def _dianzan():
    if request.method != 'POST':
        return 'methods not allowed!'
    try:
        qq = request.form.get('qq', '')
        pwd = request.form.get('pwd', '')
        cnt = request.form.get('cnt', '1')
        feq = request.form.get('feq', '10')  # 点赞次数
        inc = request.form.get('inc', '10')
        frr = request.form.get('frr', '')
        pos = request.form.get('pos', '')
        neg = request.form.get('neg', '')

        try:D = dianzan.Dianzan(qq = qq, pwd = pwd, cnt = int(cnt), feq = int(feq), inc = int(inc))
        except Exception as e: print e; traceback.print_exc(file = sys.stdout)


        ret = D.dianzan(cnt = int(cnt))

        try:
            feq = int(feq)
            inc = int(inc)

            if (feq * inc - inc) > 0:
                db = init_db()
                add_task(db, uid = D.qq, url = D.url, ttl = feq * inc - inc, inc = inc, pos = pos, neg = neg)
        except Exception as e:
            logging.error('/dianzan:' + str(e))
            traceback.print_exc(file=sys.stdout)

        if str(frr) == "on":
            try:ret = D.get_friend()
            except:ret={}
            if len(ret) == 0:
                return '''
                        <html>
                        <body>
                            </p>妈蛋, 好像获取好友列表失败了,<a href="/">再试一次</a>吧</p>
                        </body>
                        </html>

                        '''
            return render_template('select_friend.html', frr = ret)

    except Exception as e:
        #logging.error(str(e))
        print str(e)
        traceback.print_exc(file=sys.stdout)
        ret = "<p>%s</p>"%("用户名,密码或者验证码错误!请再试一次")
        ret += '<script> console.log("%s") </script>' % str(e)
    return ret
Exemple #4
0
def comment():
  db = init_db()
  cursor = db.cursor()
  cursor.execute('''select * from feedback order by id DESC''')
  ret = cursor.fetchall()
  ret_list = []
  for _ in ret:
    try:
      ret_list.append([ _[1].decode('utf-8'), _[2].decode('utf-8', ''), _[3].decode('utf-8', '') ])
    except Exception as e:
      print str(e)
      import traceback, sys
      traceback.print_exc(file=sys.stdout)
      #ret_list = [ ['error', 'error', 'error'] ]
  return render_template('feedback.html', comments = ret_list)
Exemple #5
0
def feedback():
    db = init_db()
    nickname = request.form.get('nickname', '这个人很懒什么都没留下')
    contact = request.form.get('contact', '这个人很懒什么都没留下')
    comment = request.form.get('comment', '妈蛋, 这个人什么都没写')

    import MySQLdb
    nickname = MySQLdb.escape_string(nickname)
    contact = MySQLdb.escape_string(contact)
    comment = MySQLdb.escape_string(comment)
    sql = r'''
                insert feedback (nickname, contact, comment) values ("%s", "%s", "%s");
        ''' % (nickname, contact, comment)
    cursor = db.cursor()
    cursor.execute(sql)
    db.commit()
    db.close()
    return r'''
Exemple #6
0
def feedback():
    db = init_db()
    nickname = request.form.get('nickname', '这个人很懒什么都没留下').strip()  # T_T  这样不管用,,当为空时得到的就是空字符串,,,我这个傻逼
    contact = request.form.get('contact', '这个人很懒什么都没留下').strip()
    comment = request.form.get('comment', '妈蛋, 这个人什么都没写').strip()

    if not nickname: nickname = '这个人很懒什么都没留下'
    if not contact: contact = '这个人很懒什么都没留下'
    if not comment: comment = '妈蛋,这个人太懒了吧! 什么都没写...'

    import MySQLdb
    nickname = MySQLdb.escape_string(nickname)
    contact = MySQLdb.escape_string(contact)
    comment = MySQLdb.escape_string(comment)
    sql = r'''
                insert feedback (nickname, contact, comment) values ("%s", "%s", "%s");
        ''' % (nickname, contact, comment)
    cursor = db.cursor()
    cursor.execute(sql)
    db.commit()
    db.close()
    return r'''
Exemple #7
0
    )

app.config.from_object('application.config')

import urllib
@app.template_filter('urlquote')
def urlquote(uri):
  return urllib.quote(uri)
app.jinja_env.globals['urlquote'] = urlquote

@app.before_request
def before_request():
    pass

from application.apps.db_methods import init_db
db = init_db()

@app.teardown_request
def teardown_request(exception):
    try:db.close()
    except:pass

# views
from application.views import index
# control
from application.control import qq
from application.control import user
from application.control import kvdbmanage
# apps
from application.apps import proxy
Exemple #8
0
 def _test_db(self):
     db = init_db()
     add_task(db, uid = 'ts', url = 'ts')
Exemple #9
0
def _dianzan():
    try:
        qq = request.form.get('qq', '')
        pwd = request.form.get('pwd', '')
        cnt = request.form.get('cnt', '1')
        feq = request.form.get('feq', '10')  # 点赞次数
        inc = request.form.get('inc', '10')
        frr = request.form.get('frr', '')
        pos = request.form.get('pos', '')
        neg = request.form.get('neg', '')
        remember = request.form.get('remember', '')
        _url = None
        data = {}
        data['remember'] = remember
        if remember == "on" and session.get('qq') == qq:
          with kvdbwrap.KVDB() as kv:
            try:
              ret = kv.get('qq#%s' % qq)
              data = json.loads(ret)
            except Exception as e:
              print str(e)
              import sys, traceback
              traceback.print_exc(file=sys.stdout)
          data['remember'] = 'on'
        else:
          if 'qq' in session:
            session.pop('qq', None)

        data.update({
          'qq': qq,
          'pwd': pwd,
          'cnt': cnt,
          'feq': feq,
          'inc': inc,
          'frr': frr,
          'pos': pos,
          'neg': neg
          })
        try:
          D = dianzan.Dianzan(**data)
          #D = dianzan.Dianzan(
          #                    qq = qq, 
          #                    pwd = pwd,
          #                    cnt = int(cnt),
          #                    feq = int(feq),
          #                    inc = int(inc),
          #                    pos = pos,
          #                    neg = neg,
          #                    url = _url
          #                    )
        except Exception as e:
          print e
          traceback.print_exc(file = sys.stdout)


        ret = D.dianzan(cnt = int(cnt))

        try:
            feq = int(feq)
            inc = int(inc)

            if (feq * inc - inc) > 0:
                db = init_db()
                add_task(db, uid = D.qq, url = D.url, ttl = feq * inc - inc, inc = inc, pos = pos, neg = neg)
        except Exception as e:
            logging.error('/dianzan:' + str(e))
            traceback.print_exc(file=sys.stdout)

        if str(frr) == "on":
            try:ret = D.get_friend()
            except:ret={}
            if len(ret) == 0:
                return '''
                        <html>
                        <body>
                            </p>妈蛋, 好像获取好友列表失败了,<a href="/">再试一次</a>吧</p>
                        </body>
                        </html>

                        '''
            return render_template('select_friend.html', frr = ret)

    except Exception as e:
        #logging.error(str(e))
        print str(e)
        import traceback, sys
        traceback.print_exc(file=sys.stdout)
        ret = "<p>%s</p>"%("用户名,密码或者验证码错误!请再试一次")
        ret += '<script> console.log("%s") </script>' % str(e)
    return ret