| OLD | NEW |
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 | 2 |
| 3 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
| 4 # Copyright (C) 2006-2016 Eyeo GmbH | 4 # Copyright (C) 2006-2016 Eyeo GmbH |
| 5 # | 5 # |
| 6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify |
| 7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as |
| 8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
| 9 # | 9 # |
| 10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 UPDATE type = %(type)s, site = %(site)s, comment = %(comment)s,
status = %(status)s, | 103 UPDATE type = %(type)s, site = %(site)s, comment = %(comment)s,
status = %(status)s, |
| 104 hasscreenshot = %(hasscreenshot)s, knownissues = %(knownissues)
s, dump = %(dump)s''', | 104 hasscreenshot = %(hasscreenshot)s, knownissues = %(knownissues)
s, dump = %(dump)s''', |
| 105 {'guid': guid, 'type': reportData.get('type', None), 'ctime': r
eportData['time'], 'site': reportData.get('siteName', None), | 105 {'guid': guid, 'type': reportData.get('type', None), 'ctime': r
eportData['time'], 'site': reportData.get('siteName', None), |
| 106 'comment': reportData.get('comment', None), 'status': reportDa
ta.get('status', None), 'contact': contact, | 106 'comment': reportData.get('comment', None), 'status': reportDa
ta.get('status', None), 'contact': contact, |
| 107 'hasscreenshot': reportData.get('hasscreenshot', 0), 'knowniss
ues': knownIssues, 'dump': dumpstr}) | 107 'hasscreenshot': reportData.get('hasscreenshot', 0), 'knowniss
ues': knownIssues, 'dump': dumpstr}) |
| 108 if len(reportData['subscriptions']) > 0: | 108 if len(reportData['subscriptions']) > 0: |
| 109 for sn in reportData['subscriptions']: | 109 for sn in reportData['subscriptions']: |
| 110 executeQuery(cursor, 'SELECT id FROM #PFX#subscriptions WHERE url =
%s', sn['id']) | 110 executeQuery(cursor, 'SELECT id FROM #PFX#subscriptions WHERE url =
%s', sn['id']) |
| 111 id = cursor.fetchone() | 111 id = cursor.fetchone() |
| 112 if id != None: | 112 if id != None: |
| 113 filterMatch = lambda f: any(u == sn['id'] for u in f.get('subscr
iptions', [])) | 113 def filterMatch(f): |
| 114 return any(u == sn['id'] for u in f.get('subscriptions', [])
) |
| 114 hasMatches = any(filterMatch(f) for f in reportData.get('filters
', [])) | 115 hasMatches = any(filterMatch(f) for f in reportData.get('filters
', [])) |
| 115 executeQuery(cursor, 'INSERT IGNORE INTO #PFX#sublists (report,
list, hasmatches) VALUES (%s, %s, %s)', (guid, id[0], hasMatches)) | 116 executeQuery(cursor, 'INSERT IGNORE INTO #PFX#sublists (report,
list, hasmatches) VALUES (%s, %s, %s)', (guid, id[0], hasMatches)) |
| 116 | 117 |
| 117 get_db().commit() | 118 get_db().commit() |
| 118 | 119 |
| 119 reportData['guid'] = guid | 120 reportData['guid'] = guid |
| 120 if contact: | 121 if contact: |
| 121 # TODO: The mail anonymization should happen in the template, not here | 122 # TODO: The mail anonymization should happen in the template, not here |
| 122 origEmail = reportData['email'] | 123 origEmail = reportData['email'] |
| 123 email = reportData['email'] | 124 email = reportData['email'] |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 if os.name == 'nt': | 274 if os.name == 'nt': |
| 274 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_un
icode=True, charset='utf8', named_pipe=True) | 275 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_un
icode=True, charset='utf8', named_pipe=True) |
| 275 else: | 276 else: |
| 276 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_un
icode=True, charset='utf8') | 277 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_un
icode=True, charset='utf8') |
| 277 | 278 |
| 278 | 279 |
| 279 def executeQuery(cursor, query, args=None): | 280 def executeQuery(cursor, query, args=None): |
| 280 tablePrefix = get_config().get('reports', 'dbprefix') | 281 tablePrefix = get_config().get('reports', 'dbprefix') |
| 281 query = re.sub(r'#PFX#', tablePrefix, query) | 282 query = re.sub(r'#PFX#', tablePrefix, query) |
| 282 cursor.execute(query, args) | 283 cursor.execute(query, args) |
| OLD | NEW |