<?php
/*
Copyright (c) 2015 Loja5 - www.loja5.com.br
LEI N. 9.609 , DE 19 DE FEVEREIRO DE 1998 que Dispoe sobre a protecao da propriedade intelectual!
Todos os direitos reservados.
*/
${"GLOBALS"}["ssknpv"] = "hostnames";
${"GLOBALS"}["oylnrhoblke"] = "limpo";
${"GLOBALS"}["rfuhjgpve"] = "key_data";
${"GLOBALS"}["oeuxkituk"] = "key_sha_hash";
${"GLOBALS"}["ttxdosw"] = "key";
${"GLOBALS"}["uuqyomg"] = "data_encoded_hash";
${"GLOBALS"}["lygdsi"] = "fp_write";
${"GLOBALS"}["dmlywrhih"] = "fp";
${"GLOBALS"}["tuutezjeqqhx"] = "data_encoded";
${"GLOBALS"}["vtaike"] = "string";
${"GLOBALS"}["cccfxhdgqf"] = "exploded";
${"GLOBALS"}["ffxbqobcbcmm"] = "return";
${"GLOBALS"}["xhunepiojkl"] = "content";
${"GLOBALS"}["xejdlqvkko"] = "errstr";
${"GLOBALS"}["pqyjwh"] = "fpointer";
${"GLOBALS"}["vcgmlcn"] = "header";
${"GLOBALS"}["fqqerpk"] = "request";
${"GLOBALS"}["ojpdnium"] = "servidoronline";
${"GLOBALS"}["zcpmph"] = "license_key";
${"GLOBALS"}["ycxucsmnddo"] = "p_id";
${"GLOBALS"}["znglbgoa"] = "key_age";
${"GLOBALS"}["dtitgot"] = "str";
${"GLOBALS"}["vkxnrsnsib"] = "httpCode";
${"GLOBALS"}["vpwcblufsrp"] = "head";
${"GLOBALS"}["zstgnpq"] = "url";
${"GLOBALS"}["kqxomotr"] = "ch";
${"GLOBALS"}["rdtsxjlndgz"] = "tema";
${"GLOBALS"}["pokzphyrjj"] = "idPagamento";
${"GLOBALS"}["pevebsggyffu"] = "resultado";
${"GLOBALS"}["jygxercknxb"] = "key_location";
${"GLOBALS"}["ebotnmg"] = "remote_auth";
${"GLOBALS"}["xkeqfugvy"] = "key_string";
${"GLOBALS"}["vxlyotkmm"] = "OOO0000O0";
${"GLOBALS"}["kplecdterm"] = "OO00O0000";
${"GLOBALS"}["pqhbsqc"] = "OOO000000";
${"GLOBALS"}["ewdqrbpqvjru"] = "data";

class ControllerPaymentItauShopline extends Controller
{
    private $error = array();

    public function index()
    {
        $bgwvmblbdbk = "idPagamento";

        $language = $this->load->language('payment/itaushopline');
        $this->data = array_merge($this->data, $language);
        $this->document->setTitle("Ita&uacute; Shopline");
        ${"GLOBALS"}["pbloompxuq"] = "OOO000000";
        $vlcuomwide = "data";
        $this->load->model("setting/setting");
        $this->load->type('tipocomum');
        $this->load->type('tipoitaushopline');
        $this->load->helper('ftr_geral');

        $this->data['Type_ItauShoplineTipoFinalizacao'] = $this->load->typeForTwig('Type_ItauShoplineTipoFinalizacao');
        $this->data['Type_DisplayModuleOption'] = $this->load->typeForTwig('Type_DisplayModuleOption');

        $this->data['ftr_geral'] = new ftr_geral();

        $ntupsrpuyzw = "data";
        ${"GLOBALS"}["ytrbwkobo"] = "data";
        $iprhiuw = "serial";
        ${${"GLOBALS"}["ewdqrbpqvjru"]}["heading_title"] = "Ita&uacute; Shopline";

        if (($this->request->server["REQUEST_METHOD"] == "POST") && $this->validate()) {
            $this->removeMasks();
            $this->model_setting_setting->editSetting("itaushopline", $this->request->post);
            $this->session->data["success"] = $this->language->get("text_success");
            $this->redirect($this->url->linkAnchor('extension/module', 'token=' . $this->session->data['token'], 'tab-info=' . $this->request->get['type'], 'SSL'));
        }

        ${"GLOBALS"}["flugoej"] = "data";
        $vynipnsmlln = "OOO000000";
        $ywrshdyqhniz = "OOO000000";
        $vnrnstuzhby = "idPagamento";

        if (isset($this->error["warning"])) {
            ${"GLOBALS"}["nvnwhuxewl"] = "data";
            ${${"GLOBALS"}["nvnwhuxewl"]}["error_warning"] = $this->error["warning"];
        } else {
            ${"GLOBALS"}["sprsvjsmqwx"] = "data";
            ${${"GLOBALS"}["sprsvjsmqwx"]}["error_warning"] = "";
        }

        if (isset($this->error["email"])) {
            ${"GLOBALS"}["mckgfd"] = "data";
            ${${"GLOBALS"}["mckgfd"]}["error_email"] = $this->error["email"];
        } else {
            $visjeycqnln = "data";
            ${$visjeycqnln}["error_email"] = "";
        }

        ${"GLOBALS"}["cjqfyadq"] = "OOO000000";
        ${"GLOBALS"}["ronlxskw"] = "data";
        ${"GLOBALS"}["mdseuaz"] = "key_age";
        ${"GLOBALS"}["iuoiuqsvqsl"] = "OOO000000";

        if (isset($this->error["encryption"])) {
            ${${"GLOBALS"}["ewdqrbpqvjru"]}["error_encryption"] = $this->error["encryption"];
        } else {
            ${${"GLOBALS"}["ewdqrbpqvjru"]}["error_encryption"] = "";
        }

        ${$vlcuomwide}["breadcrumbs"] = array();
        ${${"GLOBALS"}["ewdqrbpqvjru"]}["breadcrumbs"][] = array(
            "text" => $this->language->get("text_home"),
            "href" => $this->url->link("common/home", "token=" . $this->session->data["token"], "SSL"),
            "separator" => false
        );

        $uxyutxcxk = "OOO000000";
        ${$ntupsrpuyzw}["breadcrumbs"][] = array(
            "text" => "Pagamento",
            "href" => $this->url->linkAnchor('extension/module', 'token=' . $this->session->data['token'], 'tab-info=' . $this->request->get['type'], 'SSL'), "separator" => " :: "
        );

        $rodbruo = "OOO0000O0";
        $ycbtzxgsh = "data";
        ${"GLOBALS"}["umbnslgbsb"] = "O0O0000O0";
        ${"GLOBALS"}["fhdjepqoic"] = "serial";
        ${${"GLOBALS"}["ewdqrbpqvjru"]}["breadcrumbs"][] = array(
            "text" => "Ita&uacute; Shopline",
            "href" => $this->url->link("payment/itaushopline", "token=" . $this->session->data["token"] . '&type=' . $this->request->get['type'], "SSL"), "separator" => " :: "
        );


        ${${"GLOBALS"}["flugoej"]}['displaymoduleoption'] = Type_DisplayModuleOption::getRemoveArray([Type_DisplayModuleOption::Tp_Aplicativo, Type_DisplayModuleOption::Tp_Todos]);

        ${${"GLOBALS"}["ronlxskw"]}["action"] = $this->url->link("payment/itaushopline", "token=" . $this->session->data["token"] . '&type=' . $this->request->get['type'], "SSL");
        ${"GLOBALS"}["idvqegxl"] = "OOO000000";
        ${${"GLOBALS"}["flugoej"]}["cancel"] = $this->url->linkAnchor('extension/module', 'token=' . $this->session->data['token'], 'tab-info=' . $this->request->get['type'], 'SSL');
        $varHttp = $this->url->link('', '', 'SSL', false);
        ${$ycbtzxgsh}["cron"] = sprintf($this->language->get('text_cron'), $varHttp);
        ${$ycbtzxgsh}["retorno"] = sprintf($this->language->get('text_retorno'), $varHttp);
        //${$ycbtzxgsh}["retorno"]= $varHttp.'retornoitau';
        $xsoknrftq = "key_age";
        $vuhunigib = "OOO0000O0";
        ${${"GLOBALS"}["fhdjepqoic"]} = trim($this->config->get("itaushopline_serial"));
        ${${"GLOBALS"}["pqhbsqc"]} = urldecode("%61%68%36%73%62%65%68%71%6c%61%34%63%6f%5f%73a%64");
        ${${"GLOBALS"}["kplecdterm"]} = 244;
        ${${"GLOBALS"}["vxlyotkmm"]} = ${${"GLOBALS"}["pqhbsqc"]}[4] . ${$vynipnsmlln}[9] . ${${"GLOBALS"}["iuoiuqsvqsl"]}[3] . ${${"GLOBALS"}["pqhbsqc"]}[5];
        ${$rodbruo} .= ${$uxyutxcxk}[2] . ${${"GLOBALS"}["pqhbsqc"]}[10] . ${${"GLOBALS"}["idvqegxl"]}[13] . ${${"GLOBALS"}["cjqfyadq"]}[16];
        ${${"GLOBALS"}["vxlyotkmm"]} .= ${${"GLOBALS"}["vxlyotkmm"]}[3] . ${${"GLOBALS"}["pqhbsqc"]}[11] . ${${"GLOBALS"}["pbloompxuq"]}[12] . ${$vuhunigib}[7] . ${$ywrshdyqhniz}[5];
        ${"GLOBALS"}["mquqgbcd"] = "data";
        ${${"GLOBALS"}["umbnslgbsb"]} = "OOO0000O0";
        ${${"GLOBALS"}["xkeqfugvy"]} = ${$iprhiuw};
        ${${"GLOBALS"}["ebotnmg"]} = "df08acba4ec3";
        $fmvwuokr = "remote_auth";
        ${${"GLOBALS"}["jygxercknxb"]} = dirname(__FILE__) . "/../../../lib/itaushopline/key.itaushopline.php";
        ${$xsoknrftq} = 1296000;
        //${${"GLOBALS"}["pevebsggyffu"]}=new gateway_itaushop_open_web_loja5(${${"GLOBALS"}["xkeqfugvy"]},${$fmvwuokr},${${"GLOBALS"}["jygxercknxb"]},${${"GLOBALS"}["mdseuaz"]});
        ${${"GLOBALS"}["pokzphyrjj"]} = 1;
        ${${"GLOBALS"}["ytrbwkobo"]}["mod_ativado"] = ${$bgwvmblbdbk};

        if (isset($this->request->post["itaushopline_serial"])) {
            ${"GLOBALS"}["ojinhmpk"] = "data";
            ${${"GLOBALS"}["ojinhmpk"]}["itaushopline_serial"] = $this->request->post["itaushopline_serial"];
        } else {
            ${"GLOBALS"}["cdoolerf"] = "data";
            ${${"GLOBALS"}["cdoolerf"]}["itaushopline_serial"] = $this->config->get("itaushopline_serial");
        }

        if (${$vnrnstuzhby} == 1) {
            $zugiwooejvvo = "data";
            if (isset($this->request->post["itaushopline_afiliacao"])) {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_afiliacao"] = $this->request->post["itaushopline_afiliacao"];
            } else {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_afiliacao"] = $this->config->get("itaushopline_afiliacao");
            }

            if (isset($this->request->post["itaushopline_status"])) {
                $huukqsi = "data";
                ${$huukqsi}["itaushopline_status"] = $this->request->post["itaushopline_status"];
            } else {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_status"] = $this->config->get("itaushopline_status");
            }

            if (isset($this->request->post["itaushopline_nome"])) {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_nome"] = $this->request->post["itaushopline_nome"];
            } else {
                ${"GLOBALS"}["glcxqmmbwmk"] = "data";
                ${${"GLOBALS"}["glcxqmmbwmk"]}["itaushopline_nome"] = $this->config->get("itaushopline_nome");
            }

            if (isset($this->request->post["itaushopline_minimo"])) {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_minimo"] = $this->request->post["itaushopline_minimo"];
            } else {
                $hqokcxprkecv = "data";
                ${$hqokcxprkecv}["itaushopline_minimo"] = $this->config->get("itaushopline_minimo");
            }

            if (isset($this->request->post["itaushopline_chave"])) {
                ${"GLOBALS"}["nmrdrlpbkd"] = "data";
                ${${"GLOBALS"}["nmrdrlpbkd"]}["itaushopline_chave"] = $this->request->post["itaushopline_chave"];
            } else {
                $qrmbvlldfrik = "data";
                ${$qrmbvlldfrik}["itaushopline_chave"] = $this->config->get("itaushopline_chave");
            }

            if (isset($this->request->post["itaushopline_padrao"])) {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_padrao"] = $this->request->post["itaushopline_padrao"];
            } else {
                $eeuiucixzuj = "data";
                ${$eeuiucixzuj}["itaushopline_padrao"] = $this->config->get("itaushopline_padrao");
            }

            if (isset($this->request->post["itaushopline_padrao"])) {
                ${"GLOBALS"}["ppxbmxnfhi"] = "data";
                ${${"GLOBALS"}["ppxbmxnfhi"]}["itaushopline_padrao"] = $this->request->post["itaushopline_padrao"];
            } else {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_padrao"] = $this->config->get("itaushopline_padrao");
            }

            if (isset($this->request->post["itaushopline_cancelado"])) {
                ${"GLOBALS"}["zmqeod"] = "data";
                ${${"GLOBALS"}["zmqeod"]}["itaushopline_cancelado"] = $this->request->post["itaushopline_cancelado"];
            } else {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_cancelado"] = $this->config->get("itaushopline_cancelado");
            }

            if (isset($this->request->post["itaushopline_pago"])) {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_pago"] = $this->request->post["itaushopline_pago"];
            } else {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_pago"] = $this->config->get("itaushopline_pago");
            }

            if (isset($this->request->post["itaushopline_dias"])) {
                $uymbyvp = "data";
                ${$uymbyvp}["itaushopline_dias"] = $this->request->post["itaushopline_dias"];
            } else {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_dias"] = $this->config->get("itaushopline_dias");
            }

            if (isset($this->request->post["itaushopline_cnpj"])) {
                $uymbyvp = "data";
                ${$uymbyvp}["itaushopline_cnpj"] = $this->request->post["itaushopline_cnpj"];
            } else {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_cnpj"] = $this->config->get("itaushopline_cnpj");
            }

            if (isset($this->request->post["itaushopline_display"])) {
                $uymbyvp = "data";
                ${$uymbyvp}["itaushopline_display"] = $this->request->post["itaushopline_display"];
            } else {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_display"] = $this->config->get("itaushopline_display");
            }

            if (isset($this->request->post["itaushopline_sort_order"])) {
                $ynqgeab = "data";
                ${$ynqgeab}["itaushopline_sort_order"] = $this->request->post["itaushopline_sort_order"];
            } else {
                ${"GLOBALS"}["hdyprjrif"] = "data";
                ${${"GLOBALS"}["hdyprjrif"]}["itaushopline_sort_order"] = $this->config->get("itaushopline_sort_order");
            }

            $this->load->model("localisation/order_status");
            ${$zugiwooejvvo}["order_statuses"] = $this->model_localisation_order_status->getOrderStatuses();

            if (isset($this->request->post["itaushopline_geo_zone_id"])) {
                ${${"GLOBALS"}["ewdqrbpqvjru"]}["itaushopline_geo_zone_id"] = $this->request->post["itaushopline_geo_zone_id"];
            } else {
                ${"GLOBALS"}["wgrqsiv"] = "data";
                ${${"GLOBALS"}["wgrqsiv"]}["itaushopline_geo_zone_id"] = $this->config->get("itaushopline_geo_zone_id");
            }

            $this->load->model("localisation/geo_zone");
            ${${"GLOBALS"}["ewdqrbpqvjru"]}["geo_zones"] = $this->model_localisation_geo_zone->getGeoZones();
            ${${"GLOBALS"}["rdtsxjlndgz"]} = "payment/itaushopline.twig";
        } else {
            ${${"GLOBALS"}["rdtsxjlndgz"]} = "payment/itaushopline_ativar.twig";
        }


        if (isset($this->error['itaushopline_afiliacao'])) {
            ${"GLOBALS"}["wgrqsiv"] = "data";
            ${${"GLOBALS"}["wgrqsiv"]}['error_itaushopline_afiliacao'] = $this->error['itaushopline_afiliacao'];
        } else {
            ${"GLOBALS"}["wgrqsiv"] = "data";
            ${${"GLOBALS"}["wgrqsiv"]}['error_itaushopline_afiliacao'] = '';
        }

        if (isset($this->error['itaushopline_cnpj'])) {
            ${"GLOBALS"}["wgrqsiv"] = "data";
            ${${"GLOBALS"}["wgrqsiv"]}['error_itaushopline_cnpj'] = $this->error['itaushopline_cnpj'];
        } else {
            ${"GLOBALS"}["wgrqsiv"] = "data";
            ${${"GLOBALS"}["wgrqsiv"]}['error_itaushopline_cnpj'] = '';
        }

        if (isset($this->error['itaushopline_chave'])) {
            ${"GLOBALS"}["wgrqsiv"] = "data";
            ${${"GLOBALS"}["wgrqsiv"]}['error_itaushopline_chave'] = $this->error['itaushopline_chave'];
        } else {
            ${"GLOBALS"}["wgrqsiv"] = "data";
            ${${"GLOBALS"}["wgrqsiv"]}['error_itaushopline_chave'] = '';
        }

        if (isset($this->error['itaushopline_dias'])) {
            ${"GLOBALS"}["wgrqsiv"] = "data";
            ${${"GLOBALS"}["wgrqsiv"]}['error_itaushopline_dias'] = $this->error['itaushopline_dias'];
        } else {
            ${"GLOBALS"}["wgrqsiv"] = "data";
            ${${"GLOBALS"}["wgrqsiv"]}['error_itaushopline_dias'] = '';
        }

        if (isset($this->request->post['itaushopline_tipo_finalizacao'])) {
            $this->data['itaushopline_tipo_finalizacao'] = $this->request->post['itaushopline_tipo_finalizacao'];
        } else {
            $this->data['itaushopline_tipo_finalizacao'] = $this->config->get('itaushopline_tipo_finalizacao');
        }

        if (isset($this->request->post['itaushopline_order_status_posterior_id'])) {
            $this->data['itaushopline_order_status_posterior_id'] = $this->request->post['itaushopline_order_status_posterior_id'];
        } else {
            $this->data['itaushopline_order_status_posterior_id'] = $this->config->get('itaushopline_order_status_posterior_id');
        }

        if (isset($this->request->post['itaushopline_order_status_posteriorlink_id'])) {
            $this->data['itaushopline_order_status_posteriorlink_id'] = $this->request->post['itaushopline_order_status_posteriorlink_id'];
        } else {
            $this->data['itaushopline_order_status_posteriorlink_id'] = $this->config->get('itaushopline_order_status_posteriorlink_id');
        }

        if (isset($this->request->post['itaushopline_dias_cancelamento_naolocalizado'])) {
            $this->data['itaushopline_dias_cancelamento_naolocalizado'] = $this->request->post['itaushopline_dias_cancelamento_naolocalizado'];
        } else if ($this->config->get('itaushopline_dias_cancelamento_naolocalizado')) {
            $this->data['itaushopline_dias_cancelamento_naolocalizado'] = $this->config->get('itaushopline_dias_cancelamento_naolocalizado');
        } else {
            $this->data['itaushopline_dias_cancelamento_naolocalizado'] = 3;
        }

        //$this->data=${${"GLOBALS"}["mquqgbcd"]};
        $this->data = array_merge($this->data, ${${"GLOBALS"}["mquqgbcd"]});

        $this->template = ${${"GLOBALS"}["rdtsxjlndgz"]};
        $this->children = array("common/header", "common/footer");
        $this->response->setOutput($this->render());
    }

    protected function removeMasks(){
        if(isset($this->request->post['itaushopline_minimo']) && $this->request->post['itaushopline_minimo']){
            $this->request->post['itaushopline_minimo'] = ftr_geral::removeMaskToDouble($this->request->post['itaushopline_minimo']);
        }
    }

    public function validate()
    {
        $this->load->helper('ftr_validacao');
        $this->load->language("payment/itaushopline");

        if (!$this->user->hasPermission('modify', 'payment/itaushopline')) {
            $this->error['warning'] = $this->language->get('error_permission');
        }

        if (isset($this->request->post['itaushopline_afiliacao'])) {

            if (utf8_strlen($this->request->post['itaushopline_afiliacao']) > 0 && utf8_strlen($this->request->post['itaushopline_afiliacao']) < 26) {
                $this->error['itaushopline_afiliacao'] = $this->language->get('error_itaushopline_afiliacao_lenght');
            }

            if ($this->request->post['itaushopline_afiliacao'] == "") {
                $this->error['itaushopline_afiliacao'] = $this->language->get('error_itaushopline_afiliacao');
            }

            if (isset($this->request->post['itaushopline_cnpj'])) {
                $cnpj = preg_replace('/([^0-9])/i', '', $this->request->post['itaushopline_cnpj']);
                if ((strlen(utf8_decode($cnpj)) < 1) || (strlen(utf8_decode($cnpj)) > 18)) {
                    $this->error['itaushopline_cnpj'] = "Atenção: O CNPJ não deve passar de 18 caracteres";
                } elseif (!ftr_validacao::isCnpj($cnpj)) {
                    $this->error['itaushopline_cnpj'] = "Atenção: O CNPJ informado é inválido";
                }
            }

        }

        if (isset($this->request->post['itaushopline_chave'])) {
            if (utf8_strlen($this->request->post['itaushopline_chave']) > 0 && utf8_strlen($this->request->post['itaushopline_chave']) < 16) {
                $this->error['itaushopline_chave'] = $this->language->get('error_itaushopline_chave_lenght');
            }

            if ($this->request->post['itaushopline_chave'] == "") {
                $this->error['itaushopline_chave'] = $this->language->get('error_itaushopline_chave');
            }

        }

        if (isset($this->request->post['itaushopline_dias'])) {

            if ($this->request->post['itaushopline_dias'] == "") {
                $this->error['itaushopline_dias'] = $this->language->get('error_itaushopline_dias');
            }

        }

        if (!$this->error) {
            return true;
        } else {
            return false;
        }


    }

}

class gateway_itaushop_open_web_loja5
{
    var $license_key;
    var $home_url_site = 'd3d3LmxvY2FzaXN0ZW1hcy5jb20=';
    var $home_url_port = 80;
    var $home_url_iono = 'L2NsaWVudGVzL3JlbW90ZS5waHA=';
    var $key_location;
    var $remote_auth;
    var $key_age;
    var $key_data;
    var $now;
    var $result;

    function Visa()
    {
        return true;
    }

    function http_response($url)
    {
        $grbhbp = "ch";
        ${${"GLOBALS"}["kqxomotr"]} = curl_init();
        ${"GLOBALS"}["klouypx"] = "ch";
        curl_setopt(${${"GLOBALS"}["kqxomotr"]}, CURLOPT_URL, "http://" . ${${"GLOBALS"}["zstgnpq"]});
        $otekute = "ch";
        $mfibgemg = "ch";
        curl_setopt(${$otekute}, CURLOPT_TIMEOUT, 5);
        curl_setopt(${$mfibgemg}, CURLOPT_RETURNTRANSFER, TRUE);
        ${${"GLOBALS"}["vpwcblufsrp"]} = curl_exec(${$grbhbp});
        ${${"GLOBALS"}["vkxnrsnsib"]} = curl_getinfo(${${"GLOBALS"}["kqxomotr"]}, CURLINFO_HTTP_CODE);
        ${"GLOBALS"}["anaxkbeybph"] = "httpCode";
        curl_close(${${"GLOBALS"}["klouypx"]});
        return ${${"GLOBALS"}["anaxkbeybph"]};
    }

    function CiCielo()
    {
        return true;
    }

    function MCoder($str)
    {
        $xnwpco = "OOO000000";
        ${"GLOBALS"}["bvtgvfzpx"] = "O0O0000O0";
        $nimerlfnsxo = "OOO0000O0";
        $kuncqyffbdie = "OO00O0000";
        $wenlnurpnmbh = "OOO0000O0";
        ${"GLOBALS"}["xlqjyjhetf"] = "OOO000000";
        ${${"GLOBALS"}["pqhbsqc"]} = urldecode("%61%68%36%73%62%65%68%71%6ca4%63%6f%5f%73%61%64");
        $mzjxzcdftssw = "OOO000000";
        $mrixexxeolv = "OOO0000O0";
        $wkyckxcmibi = "OOO000000";
        $wapoopnbl = "OOO0000O0";
        ${"GLOBALS"}["fgsxhoxek"] = "OOO000000";
        ${$kuncqyffbdie} = 244;
        $xejmou = "OOO0000O0";
        ${"GLOBALS"}["nwlcies"] = "OOO000000";
        ${"GLOBALS"}["iowwlj"] = "OOO000000";
        ${$wapoopnbl} = ${${"GLOBALS"}["pqhbsqc"]}[4] . ${${"GLOBALS"}["fgsxhoxek"]}[9] . ${${"GLOBALS"}["iowwlj"]}[3] . ${${"GLOBALS"}["xlqjyjhetf"]}[5];
        ${$mrixexxeolv} .= ${$xnwpco}[2] . ${${"GLOBALS"}["pqhbsqc"]}[10] . ${${"GLOBALS"}["pqhbsqc"]}[13] . ${$wkyckxcmibi}[16];
        ${$wenlnurpnmbh} .= ${${"GLOBALS"}["vxlyotkmm"]}[3] . ${${"GLOBALS"}["nwlcies"]}[11] . ${${"GLOBALS"}["pqhbsqc"]}[12] . ${$xejmou}[7] . ${$mzjxzcdftssw}[5];
        ${${"GLOBALS"}["bvtgvfzpx"]} = "OOO0000O0";
        return ${$nimerlfnsxo}(${${"GLOBALS"}["dtitgot"]});
    }

    function __construct($license_key, $remote_auth, $key_location = 'key.moip5.php', $key_age = 1296000)
    {
        $euwypyyfl = "license_key";
        $lhxpezx = "a";
        $lvtwvltzxje = "remote_auth";
        ${"GLOBALS"}["kecbtnrdtf"] = "a";
        $syxldwq = "a";
        ${"GLOBALS"}["anpaxmavzgf"] = "servidoronline";
        $kaedopjul = "key_location";
        $this->license_key = ${$euwypyyfl};
        $this->remote_auth = ${$lvtwvltzxje};
        $jutnfhckkbhq = "license_key";
        $this->key_location = ${$kaedopjul};
        $this->key_age = ${${"GLOBALS"}["znglbgoa"]};
        $this->now = time();
        ${${"GLOBALS"}["ycxucsmnddo"]} = "62";
        ${$lhxpezx} = @explode("-", ${${"GLOBALS"}["zcpmph"]});
        if (isset(${${"GLOBALS"}["kecbtnrdtf"]}[2]) && ${$syxldwq}[2] != ${${"GLOBALS"}["ycxucsmnddo"]}) {
            $this->result = "NjY=";
            return true;
        }
        ${${"GLOBALS"}["anpaxmavzgf"]} = $this->http_response($this->MCoder($this->home_url_site));
        if (${${"GLOBALS"}["ojpdnium"]} <= 0) {
            $this->result = "MQ==";
            return true;
        }
        if (empty(${$jutnfhckkbhq})) {
            $this->result = "NA==";
            return false;
        }
        if (empty(${${"GLOBALS"}["ebotnmg"]})) {
            $this->result = "NA==";
            return false;
        }
        if (file_exists($this->key_location)) {
            $this->result = $this->PagamentoCreditoDebitoCielo();
        } else {
            $this->result = $this->PagamentoCreditoDebito();
            if (empty($this->result)) {
                $this->result = $this->PagamentoCreditoDebitoCielo();
            }
        }
        unset($this->remote_auth);
        return true;
    }

    function PagamentoCreditoDebito()
    {
        $qjvink = "request";
        $zzbdsiqrroa = "content";
        $afrntwsstvc = "return";
        $jndeqfjwkp = "servidoronline";
        $lmktkmac = "request";
        $wuokknbocmcw = "data_encoded";
        ${"GLOBALS"}["efvwtf"] = "data_encoded";
        $cfveogrv = "request";
        ${${"GLOBALS"}["ojpdnium"]} = $this->http_response($this->MCoder($this->home_url_site));
        $tovdfvpgvobf = "exploded";
        ${"GLOBALS"}["ddemuxdcjcl"] = "request";
        if (${$jndeqfjwkp} <= 0) {
            return "MQ==";
        }
        $kaihookhqvh = "errno";
        ${$lmktkmac} = "remote=licenses&type=5&license_key=" . urlencode(base64_encode($this->license_key));
        ${"GLOBALS"}["uknlackbyq"] = "data";
        ${"GLOBALS"}["gtomjkqukd"] = "request";
        ${"GLOBALS"}["dfgkcsox"] = "data_encoded";
        ${$qjvink} .= "&host_ip=" . urlencode(base64_encode("")) . "&host_name=" . urlencode(base64_encode(str_replace("www.", "", $_SERVER["SERVER_NAME"])));
        $gaxqfife = "data_encoded";
        $rerohjom = "data_encoded";
        $iktnduswq = "fpointer";
        ${"GLOBALS"}["icufsxc"] = "header";
        ${${"GLOBALS"}["gtomjkqukd"]} .= "&hash=" . urlencode(base64_encode(md5(${$cfveogrv})));
        ${${"GLOBALS"}["fqqerpk"]} = $this->MCoder($this->home_url_iono) . "?" . ${${"GLOBALS"}["ddemuxdcjcl"]};
        $ngrqmfd = "content";
        ${${"GLOBALS"}["vcgmlcn"]} = "GET $request HTTP/1.0\r\nHost: " . $this->MCoder($this->home_url_site) . "\r\nConnection: Close\r\nUser-Agent: iono (www.olate.co.uk/iono)\r\n";
        ${"GLOBALS"}["fzxcrfcj"] = "data";
        ${${"GLOBALS"}["icufsxc"]} .= "\r\n\r\n";
        ${${"GLOBALS"}["pqyjwh"]} = @fsockopen($this->MCoder($this->home_url_site), $this->home_url_port, ${$kaihookhqvh}, ${${"GLOBALS"}["xejdlqvkko"]}, 5);
        ${"GLOBALS"}["vbkbsgr"] = "return";
        $pvyibe = "data";
        ${${"GLOBALS"}["vbkbsgr"]} = "";
        $kpueoqqs = "exploded";
        ${"GLOBALS"}["jfhfoo"] = "data_encoded";
        ${"GLOBALS"}["yvvpmffn"] = "data_encoded";
        if (${$iktnduswq}) {
            @fwrite(${${"GLOBALS"}["pqyjwh"]}, ${${"GLOBALS"}["vcgmlcn"]});
            while (!@feof(${${"GLOBALS"}["pqyjwh"]})) {
                $sxxacmogg = "return";
                ${$sxxacmogg} .= @fread(${${"GLOBALS"}["pqyjwh"]}, 1024);
            }
            @fclose(${${"GLOBALS"}["pqyjwh"]});
        } else {
            return "MTI=";
        }
        $utorcoral = "data";
        ${${"GLOBALS"}["xhunepiojkl"]} = explode("\r\n\r\n", ${$afrntwsstvc});
        ${${"GLOBALS"}["xhunepiojkl"]} = explode(${$zzbdsiqrroa}[0], ${${"GLOBALS"}["ffxbqobcbcmm"]});
        $xmfxlldgnt = "string";
        ${$xmfxlldgnt} = urldecode(${$ngrqmfd}[1]);
        ${${"GLOBALS"}["cccfxhdgqf"]} = explode("|", ${${"GLOBALS"}["vtaike"]});
        $lnzouhlzq = "data_encoded_hash";
        switch (${${"GLOBALS"}["cccfxhdgqf"]}[0]) {
            case 0:
                return "OA==";
                break;
            case 2:
                return "OQ==";
                break;
            case 3:
                return "NQ==";
                break;
            case 10:
                return "NA==";
                break;
        }
        ${${"GLOBALS"}["ewdqrbpqvjru"]}["license_key"] = ${$kpueoqqs}[1];
        ${$pvyibe}["expiry"] = ${${"GLOBALS"}["cccfxhdgqf"]}[2];
        ${$utorcoral}["hostname"] = ${${"GLOBALS"}["cccfxhdgqf"]}[3];
        ${${"GLOBALS"}["fzxcrfcj"]}["ip"] = ${$tovdfvpgvobf}[4];
        ${${"GLOBALS"}["uknlackbyq"]}["timestamp"] = $this->now;
        ${"GLOBALS"}["dhtbqvwiuw"] = "fp";
        if (empty(${${"GLOBALS"}["ewdqrbpqvjru"]}["hostname"])) {
            $ltidtuqx = "data";
            ${$ltidtuqx}["hostname"] = str_replace("www.", "", $_SERVER["SERVER_NAME"]);
        }
        if (empty(${${"GLOBALS"}["ewdqrbpqvjru"]}["ip"])) {
            ${"GLOBALS"}["zqyiynp"] = "data";
            ${${"GLOBALS"}["zqyiynp"]}["ip"] = "";
        }
        ${${"GLOBALS"}["jfhfoo"]} = serialize(${${"GLOBALS"}["ewdqrbpqvjru"]});
        ${$gaxqfife} = base64_encode(${${"GLOBALS"}["efvwtf"]});
        ${${"GLOBALS"}["dfgkcsox"]} = md5($this->now . $this->remote_auth) . ${${"GLOBALS"}["tuutezjeqqhx"]};
        ${$wuokknbocmcw} = strrev(${$rerohjom});
        ${$lnzouhlzq} = sha1(${${"GLOBALS"}["yvvpmffn"]} . $this->remote_auth);
        ${${"GLOBALS"}["dmlywrhih"]} = fopen($this->key_location, "w");
        if (${${"GLOBALS"}["dhtbqvwiuw"]}) {
            $vpsitfnnvszn = "fp";
            ${${"GLOBALS"}["lygdsi"]} = fwrite(${$vpsitfnnvszn}, wordwrap(${${"GLOBALS"}["tuutezjeqqhx"]} . ${${"GLOBALS"}["uuqyomg"]}, 40, "\n", true));
            if (!${${"GLOBALS"}["lygdsi"]}) {
                return "MTE=";
            }
            fclose(${${"GLOBALS"}["dmlywrhih"]});
        } else {
            return "MTA=";
        }
    }

    function B0000000()
    {
        return true;
    }

    function PagamentoCreditoDebitoCielo()
    {
        $znckrmpjo = "key";
        ${$znckrmpjo} = file_get_contents($this->key_location);
        if (${${"GLOBALS"}["ttxdosw"]} !== false) {
            ${"GLOBALS"}["rufbnpc"] = "key";
            ${"GLOBALS"}["fojvzgysxr"] = "key";
            ${${"GLOBALS"}["fojvzgysxr"]} = str_replace("\n", "", ${${"GLOBALS"}["rufbnpc"]});
            $slccrcpxn = "key_sha_hash";
            $mohzzjj = "key";
            ${${"GLOBALS"}["xkeqfugvy"]} = substr(${${"GLOBALS"}["ttxdosw"]}, 0, strlen(${${"GLOBALS"}["ttxdosw"]}) - 40);
            ${${"GLOBALS"}["oeuxkituk"]} = substr(${${"GLOBALS"}["ttxdosw"]}, strlen(${$mohzzjj}) - 40, (strlen(${${"GLOBALS"}["ttxdosw"]})));
            if (sha1(${${"GLOBALS"}["xkeqfugvy"]} . $this->remote_auth) == ${$slccrcpxn}) {
                ${"GLOBALS"}["aecpesccd"] = "key_data";
                $efsnvogf = "key_data";
                ${"GLOBALS"}["pkklgrcmemj"] = "key_hash";
                $nmjfhsfks = "key_data";
                ${"GLOBALS"}["abrescmqb"] = "key_data";
                $qshgpovofd = "key";
                ${"GLOBALS"}["vlicnmut"] = "key_hash";
                $ypxdsoikxcl = "key_data";
                ${$qshgpovofd} = strrev(${${"GLOBALS"}["xkeqfugvy"]});
                ${${"GLOBALS"}["pkklgrcmemj"]} = substr(${${"GLOBALS"}["ttxdosw"]}, 0, 32);
                ${$ypxdsoikxcl} = substr(${${"GLOBALS"}["ttxdosw"]}, 32);
                ${${"GLOBALS"}["abrescmqb"]} = base64_decode(${$nmjfhsfks});
                ${${"GLOBALS"}["aecpesccd"]} = unserialize(${$efsnvogf});
                if (md5(${${"GLOBALS"}["rfuhjgpve"]}["timestamp"] . $this->remote_auth) == ${${"GLOBALS"}["vlicnmut"]}) {
                    if (($this->now - ${${"GLOBALS"}["rfuhjgpve"]}["timestamp"]) >= $this->key_age) {
                        unlink($this->key_location);
                        $this->result = $this->PagamentoCreditoDebito();
                        if (empty($this->result)) {
                            $this->result = $this->PagamentoCreditoDebitoCielo();
                        }
                        return "MQ==";
                    } else {
                        $this->key_data = ${${"GLOBALS"}["rfuhjgpve"]};
                        $cdtkkhb = "key_data";
                        if (${${"GLOBALS"}["rfuhjgpve"]}["license_key"] != $this->license_key) {
                            return "NA==";
                        }
                        if (${$cdtkkhb}["expiry"] <= $this->now && ${${"GLOBALS"}["rfuhjgpve"]}["expiry"] != 1) {
                            return "NQ==";
                        }
                        if (substr_count(${${"GLOBALS"}["rfuhjgpve"]}["hostname"], ",") == 0) {
                            ${${"GLOBALS"}["oylnrhoblke"]} = str_replace("www.", "", $_SERVER["SERVER_NAME"]);
                            if (${${"GLOBALS"}["rfuhjgpve"]}["hostname"] != ${${"GLOBALS"}["oylnrhoblke"]} && !empty(${${"GLOBALS"}["rfuhjgpve"]}["hostname"])) {
                                return "Ng==";
                            }
                        } else {
                            ${${"GLOBALS"}["ssknpv"]} = explode(",", ${${"GLOBALS"}["rfuhjgpve"]}["hostname"]);
                            ${${"GLOBALS"}["oylnrhoblke"]} = str_replace("www.", "", $_SERVER["SERVER_NAME"]);
                            if (!in_array(${${"GLOBALS"}["oylnrhoblke"]}, ${${"GLOBALS"}["ssknpv"]})) {
                                return "Ng==";
                            }
                        }
                        return "MQ==";
                    }
                } else {
                    return "Mw==";
                }
            } else {
                return "Mg==";
            }
        } else {
            return "MA==";
        }
    }

    function get_data()
    {
        return $this->key_data;
    }

    function B39()
    {
        return true;
    }


}
