# Path: core/logger.py
# def log_enable(active):
# def encode_log(message=""):
# def get_caller(message=None):
# def info(texto=""):
# def debug(texto=""):
# def error(texto=""):


import urlparse
import re
import time
import urllib
from core import logger
    def __init__(self, response):
        self.timeout = 5
        self.domain = urlparse.urlparse(response["url"])[1]
        self.protocol = urlparse.urlparse(response["url"])[0]
        self.js_data = {}
        self.header_data = {}

        if not  "var s,t,o,p,b,r,e,a,k,i,n,g,f" in  response["data"] or "chk_jschl" in response["url"]:
          return

        try:  
          self.js_data["auth_url"] = re.compile('<form id="challenge-form" action="([^"]+)" method="get">').findall(response["data"])[0]
          self.js_data["params"] = {}
          self.js_data["params"]["jschl_vc"] = re.compile('<input type="hidden" name="jschl_vc" value="([^"]+)"/>').findall(response["data"])[0]
          self.js_data["params"]["pass"] = re.compile('<input type="hidden" name="pass" value="([^"]+)"/>').findall(response["data"])[0]
          var, self.js_data["value"] = re.compile('var s,t,o,p,b,r,e,a,k,i,n,g,f[^:]+"([^"]+)":([^\n]+)};', re.DOTALL).findall(response["data"])[0]
          self.js_data["op"] = re.compile(var + "([\+|\-|\*|\/])=([^;]+)", re.MULTILINE).findall(response["data"])
          self.js_data["wait"] =  int(re.compile("\}, ([\d]+)\);", re.MULTILINE).findall(response["data"])[0]) / 1000
        except:
          logger.debug("Metodo #1 (javascript): NO disponible")
          self.js_data = {}


        if "refresh" in response["headers"]:
          try:
            self.header_data["wait"] = int(response["headers"]["refresh"].split(";")[0])
            self.header_data["auth_url"] = response["headers"]["refresh"].split("=")[1].split("?")[0]
            self.header_data["params"] = {}
            self.header_data["params"]["pass"] = response["headers"]["refresh"].split("=")[2]
          except:

# Path: core/logger.py
# def log_enable(active):
# def encode_log(message=""):
# def get_caller(message=None):
# def info(texto=""):
# def debug(texto=""):
# def error(texto=""):


# Path: core/cloudflare(old).py
import urlparse
import re
import time
import urllib
from core import logger

    def __init__(self, response):
        self.timeout = 5
        self.domain = urlparse.urlparse(response["url"])[1]
        self.protocol = urlparse.urlparse(response["url"])[0]
        self.js_data = {}
        self.header_data = {}

        if not  "var s,t,o,p,b,r,e,a,k,i,n,g,f" in  response["data"] or "chk_jschl" in response["url"]:
          return

        try:  
          self.js_data["auth_url"] = re.compile('<form id="challenge-form" action="([^"]+)" method="get">').findall(response["data"])[0]
          self.js_data["params"] = {}
          self.js_data["params"]["jschl_vc"] = re.compile('<input type="hidden" name="jschl_vc" value="([^"]+)"/>').findall(response["data"])[0]
          self.js_data["params"]["pass"] = re.compile('<input type="hidden" name="pass" value="([^"]+)"/>').findall(response["data"])[0]
          var, self.js_data["value"] = re.compile('var s,t,o,p,b,r,e,a,k,i,n,g,f[^:]+"([^"]+)":([^\n]+)};', re.DOTALL).findall(response["data"])[0]
          self.js_data["op"] = re.compile(var + "([\+|\-|\*|\/])=([^;]+)", re.MULTILINE).findall(response["data"])
          self.js_data["wait"] =  int(re.compile("\}, ([\d]+)\);", re.MULTILINE).findall(response["data"])[0]) / 1000
        except:
          logger.debug("Metodo #1 (javascript): NO disponible")
          self.js_data = {}


        if "refresh" in response["headers"]:
          try:
            self.header_data["wait"] = int(response["headers"]["refresh"].split(";")[0])
            self.header_data["auth_url"] = response["headers"]["refresh"].split("=")[1].split("?")[0]
            self.header_data["params"] = {}
            self.header_data["params"]["pass"] = response["headers"]["refresh"].split("=")[2]
          except:

            logger.debug("Metodo #2 (headers): NO disponible")