HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //lib/python2.7/site-packages/lap/tweeps.py
#!/usr/bin/python

import os
import socket
import time
from twitter import *

socket.setdefaulttimeout(10)
tweep_cache_file = '/var/cache/locaweb-plugins/tweeps-cache.dat'

def __run__(params):
    try:
        tweep_state_file = '/var/cache/locaweb-plugins/tweeps.dat'
        interval = params.get("interval", "")
        if os.path.isfile(tweep_cache_file):
            if (time.time() - os.stat(tweep_cache_file)[8] < interval):
                msg = open(tweep_cache_file).read()
                if msg.startswith('OK'):
                    return [0, 'OK']
                else:
                    raise ValueError(msg)

        if os.path.isfile(tweep_state_file):
            last_id = open(tweep_state_file).read()
        else:
            last_id = 0

        t = Twitter(
            auth=OAuth(
                params.get('access_token'), params.get('access_token_secret'),
                params.get('consumer_key'), params.get('consumer_secret')
            )
        )

        tweeps = t.search.tweets(
            q=params.get('query', '').strip(),
            count=100,
            lang='pt',
            result_type='recent',
            since_id=last_id
        )

        if len(tweeps['statuses']) > 0:
            last_id = tweeps['statuses'][0]['id_str']
            open(tweep_state_file, 'w').write(last_id)

            parsed = [(field['user']['screen_name'], field['id_str'],field['created_at'])
                      for field in tweeps['statuses']
                      if not params.get('exclusion') in field['user']['screen_name']]

            mentions = params.get("maximun_mentions", "")
            if mentions < len(parsed):
                msg = "Found %s tweets in %s seconds" % (len(parsed), interval)
                open(tweep_cache_file, 'w').write(msg)
                raise ValueError(msg)
            open(tweep_cache_file, 'w').write('OK')
    except socket.timeout:
        return [2, "CRITICAL: Socket timeout"]
    except socket.gaierror:
        return [2, "CRITICAL: Unable to resolve domain"]
    except Exception, e:
        return [2, "CRITICAL: %s" % repr(e)]
    else:
        return [0, "OK"]