Пример #1
0
def spam_check(content, item_of_interest, request):
    """
    Uses AKISMET to check if comment is spam
    """
    akismet.USERAGENT = "David Lynch's Python library/1.0"
    my_api_key = settings.AKISMET_KEY

    try:
        real_key = akismet.verify_key(my_api_key, "http://www.YouTalkEdu.com")
        if real_key:
            is_spam = akismet.comment_check(
                my_api_key,
                "http://www.YouTalkEdu.com",
                request.META['REMOTE_ADDR'],
                request.META['HTTP_USER_AGENT'],
                request.META.get('HTTP_REFERER', ''),
                comment_content=content,
                comment_auther_email=item_of_interest.user_id.email)
            if is_spam:
                return True
            else:
                return False
    except akismet.AkismetError, e:
        print 'Something went wrong, allowing comment'
        print e.response, e.statuscode
        return False
Пример #2
0
def is_spam(comment):
	key = app.config['AKISMET_KEY']
	blog = app.config['APPLICATION_URL']
	if isinstance(comment, unicode):
		comment = comment.encode('utf8', 'ignore')
	if akismet.comment_check(key = key, blog = blog, user_ip = '127.0.0.1', user_agent = 'Mozzila/5.0 (...) Gecko/20051111 Firefox/1.5', comment_content = comment) or 'http' in comment:
		return True
	return False
Пример #3
0
def is_spam(text):
    try:
        is_spam = akismet.comment_check(my_api_key, "illustrationarchive.cardiff.ac.uk",
                                        "127.0.0.1", "Mozilla/5.0 (...) Gecko/20051111 Firefox/1.5",
                                        comment_content=text)
        return is_spam

    except akismet.AkismetError, e:
        print e.response, e.statuscode
def isspam(comment, author, ipaddress, agent = defaultagent, apikey = defaultkey):
    try:
        valid = akismet.verify_key(apikey, pageurl)
        if valid:
            return akismet.comment_check(apikey, pageurl, ipaddress, agent, comment_content = comment,
                                         comment_author_email = author, comment_type = "comment")
        else:
            print 'Invalid key'
            return False
    except akismet.AkismetError, e:
        print e.response, e.statuscode
        return False
Пример #5
0
def is_spam(comment, user_ip, user_agent):
	if check_for_spam():
		app.logger.info("\n\nAttempting to check for spam...")
		if not is_working_akismet_key():
			app.logger.info("\n\nThere was a problem verifying the supplied AKISMET_KEY. Unable to check for spam.")
			return False
		if isinstance(comment, unicode):
			comment = comment.encode('utf8', 'ignore')
		if akismet.comment_check(key=app.config['AKISMET_KEY'], blog=app.config['APPLICATION_URL'], user_ip = user_ip, user_agent = user_agent, comment_content = comment) or 'http' in comment:
			app.logger.info("Spam detected: %s" % comment )
			return True
	return False
def isspam(comment,author,ipaddress,agent=defaultagent,apikey=defaultkey):
  try:
    valid = akismet.verify_key(apikey,pageurl)
    if valid:
      return akismet.comment_check(apikey,pageurl,ipaddress,agent,comment_content=comment,comment_author_email=author,comment_type="comment")
    else:
      print ('Invalid key')
      return False
  except (akismet.AkismetError) as e:
    print (akismet.AkismetError)
    print (e.response, e.statuscode)
    return False
def isspam(comment, author, ip, agent=defaultagent, apikey=defaultkey):
  try:
    valid = akismet.verify_key(apikey, pageurl)
    if valid:
      return akismet.comment_check(apikey, pageurl, ip, agent,
          comment_content=comment, comment_author_email=author,
          comment_type='email')
    else:
      print 'Invalid key'
      return False
  except akismet.AkismetError, e:
    print e.response, e.statuscode
    return False
Пример #8
0
def test():
    try:
        real_key = akismet.verify_key(my_api_key, "illustrationarchive.cardiff.ac.uk")
        print real_key
        if real_key:
            is_spam = akismet.comment_check(my_api_key, "illustrationarchive.cardiff.ac.uk",
                                            "127.0.0.1", "Mozilla/5.0 (...) Gecko/20051111 Firefox/1.5",
                                            comment_content=spam_comment)
            if is_spam:
                print "Yup, that's spam alright."
            else:
                print "Hooray, your users aren't scum!"
    except akismet.AkismetError, e:
        print e.response, e.statuscode
Пример #9
0
def pre_save_comment(sender, **kargs):
    if 'instance' in kargs:
        comment = kargs['instance']
        print comment
        
        # If in debug mode skip this check with Akismet
        if not settings.DEBUG:
            try:
                real_key = akismet.verify_key(settings.AKISMET_KEY ,Site.objects.get_current().domain)
                if real_key:
                    is_spam = akismet.comment_check(settings.AKISMET_KEY ,Site.objects.get_current().domain, comment.ip_address, None, comment_content=comment.content)
                    if is_spam:
                        comment.is_public = False
                        print "That was spam"
            except akismet.AkismetError, e:
                print e.response, e.statuscode
Пример #10
0
def check_akismet(request, comment):
    site = request.META.get('HTTP_HOST', settings.WEBSITE_URL)
    try:
        real_key = akismet.verify_key(settings.AKISMET_KEY, site)
        if real_key:
            is_spam = akismet.comment_check(
                settings.AKISMET_KEY,
                site,
                request.META.get('REMOTE_ADDR', '127.0.0.1'),
                request.META.get('HTTP_USER_AGENT', 'unknown'),
                comment_content=comment)
            if is_spam:
                return True
            else:
                return False
    except akismet.AkismetError, e:
        print e.response, e.statuscode
Пример #11
0
def akismet_spamcheck(content, remote_addr, user_agent):
    """Returns True if spam, False if not spam"""
    try:
        real_key = akismet.verify_key(settings.AKISMET_APIKEY, \
            settings.AKISMET_URL)

        is_spam = akismet.comment_check(settings.AKISMET_APIKEY, \
            settings.AKISMET_URL, remote_addr, user_agent, \
            comment_content=content)

        if is_spam:
            return True
        else:
            return False

    except akismet.AkismetError, e:
        logging.error("%s, %s" % (e.response, e.statuscode))
Пример #12
0
def pre_save_comment(sender, **kargs):
    """
    Run comment through a markdown filter
    """
    if 'comment' in kargs:
        comment = kargs['comment']
        
        # If in debug mode skip this check with Akismet
        if not settings.DEBUG:
            try:
                real_key = akismet.verify_key(settings.AKISMET_KEY ,Site.objects.get_current().domain)
                if real_key:
                    is_spam = akismet.comment_check(settings.AKISMET_KEY ,Site.objects.get_current().domain, comment.ip_address, None, comment_content=comment.comment)
                    if is_spam:
                        comment.is_public = False
                        print "That was spam"
            except akismet.AkismetError, e:
                print e.response, e.statuscode
        
        # Apply markdown
        comment.comment = markdown(comment.comment)
Пример #13
0
    def _is_spam(self, text):
        """
        Check if user submitted a spam comment.
        """
        site = self.getSitePath()
        user_agent = self.REQUEST.get('HTTP_USER_AGENT', '')
        user_ip = self.REQUEST.get('REMOTE_ADDR', '127.0.0.1')
        text = unidecode(text)

        is_spam = False
        if has_api_key:
            try:
                akismet_key = akismet.verify_key(akismet_api_key, site)
                if akismet_key:
                    is_spam = akismet.comment_check(akismet_api_key, site, user_ip,
                                                    user_agent,
                                                    comment_content=text)
            except akismet.AkismetError:
                pass

        return is_spam
Пример #14
0
    def post(self):
        valid = True
        name = cgi.escape(self.request.get('author'))
        email = cgi.escape(self.request.get('email'))
        website = cgi.escape(self.request.get('url'))
        body = cgi.escape(self.request.get('comment'))
        articleId = cgi.escape(self.request.get('articleId'))
        slug = cgi.escape(self.request.get('slug'))
        comment_when = cgi.escape(self.request.get('comment_when'))
        
        challenge = self.request.get('recaptcha_challenge_field')
        response = self.request.get('recaptcha_response_field')
        remoteip = self.request.remote_addr
        cResponse = captcha.submit(challenge, response, "YOUR-PRIVATE-KEY", remoteip)    
        
        if not cResponse.is_valid:   
            valid = False
        
        #todo show error error = cResponse.error_code
        
        if not name:
            valid = False
        
        if not email:
            valid = False
         
        if not body:
            valid = False

        logging.info('Start user User-Agent')
        #get user agent
        userAgent = self.request.headers['User-Agent']

        site = "jsoncharts.appspot.com"

        try:
            valid = akismet.comment_check("YOUR-API-KEY", site, remoteip, userAgent, comment_content=body)
        except akismet.AkismetError, e:
            valid = False
            logging.info('error')
Пример #15
0
    def check_spam(self, comment, content_object, request):
        """
        Returns True if the comment is spam and False if it's ham.
        """
        key = self._get_key()

        if not key:
            # TODO: log a warning
            return False

        try:
            if verify_key(key, comment.site.domain):
                data = self._get_data_from_comment(comment)
                data.update({
                    # not stored on the comment model, have to get them from the request
                    'referrer': request.META.get('HTTP_REFERER', ''),
                    'user_agent': request.META.get('HTTP_USER_AGENT', '')
                })
                return comment_check(key, comment.site.domain, **data)
        except AkismetError, e:
            # TODO: log a warning with the exception
            print e.response, e.statuscode
Пример #16
0
def view_post(request, slug):
    post = get_object_or_404(Blog, slug=slug)
    if request.method == 'POST':
        is_spam = akismet.comment_check(my_api_key,"http://ditraglia.net",
          get_client_ip(request), request.META.get('HTTP_USER_AGENT'),
          comment_content=request.POST['comment'])
        if not is_spam:
          comment = Comment(
             user=request.POST['username'],
             body=request.POST['comment'],
             post=post)
          comment.save()
        else:
          return HttpResponse("PLEASE STOP SPAMMING ME")

    return render_to_response('view_post.html', {
            'comments' : Comment.objects.all()[:5],
            'tags': Tag.objects.all()[:5],
		    'categories': Category.objects.all(),
            'post': post,
		    'allposts': Blog.objects.all()[:5],
		    'comments': Comment.objects.filter(post=post),
    }, context_instance=RequestContext(request))
Пример #17
0
    def _is_spam(self, text):
        """
        Check if user submitted a spam comment.
        """
        site = self.getSitePath()
        user_agent = self.REQUEST.get('HTTP_USER_AGENT', '')
        user_ip = self.REQUEST.get('REMOTE_ADDR', '127.0.0.1')
        text = unidecode(text)

        is_spam = False
        if has_api_key:
            try:
                akismet_key = akismet.verify_key(akismet_api_key, site)
                if akismet_key:
                    is_spam = akismet.comment_check(akismet_api_key,
                                                    site,
                                                    user_ip,
                                                    user_agent,
                                                    comment_content=text)
            except akismet.AkismetError:
                pass

        return is_spam
Пример #18
0
def is_spam(comment_content, 
            author_email, 
            ip_address,
            user_agent = default_user_agent,
            api_key = default_api_key):
  try:
    is_valid = akismet.verify_key(api_key, page_url)
    if is_valid:
      return akismet.comment_check(
               api_key, 
               page_url,
               ip_address, 
               user_agent, 
               comment_content = comment_content,
               comment_auther_email = author_email,
               comment_type = "comment"
      )
    else:
      print "Invalid api key"
      return False
  except akismet.AkismetError, e:
    print e.response, e.statuscode
    return False
Пример #19
0
def spam_check(content, item_of_interest, request):
    """
    Uses AKISMET to check if comment is spam
    """
    akismet.USERAGENT = "David Lynch's Python library/1.0"
    my_api_key = settings.AKISMET_KEY

    try:
        real_key = akismet.verify_key(my_api_key,"http://www.YouTalkEdu.com")
        if real_key:
            is_spam = akismet.comment_check(
                my_api_key,"http://www.YouTalkEdu.com",request.META['REMOTE_ADDR'],
                request.META['HTTP_USER_AGENT'],
                request.META.get('HTTP_REFERER', ''),
                comment_content=content,
                comment_auther_email=item_of_interest.user_id.email)
            if is_spam:
                return True
            else:
                return False
    except akismet.AkismetError, e:
        print 'Something went wrong, allowing comment'
        print e.response, e.statuscode
        return False