AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.216.192
Web Server : Apache
System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : lrsys ( 1015)
PHP Version : 5.6.40
Disable Function : exec,passthru,shell_exec,system
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/helpers/api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/helpers/api/WiserLeadsHelper.php
<?php

use phpDocumentor\Reflection\DocBlock\Tags\Var_;
include_once __DIR__ . "/../hubspot/Hubspot.php";

class WiserLeadsHelper {

    public function postLead($data){
        $curl = curl_init();
        // $data = json_encode($data);
        curl_setopt_array($curl, array(
            CURLOPT_URL => 'https://api.wiserleads.com.br/post',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $data,
            CURLOPT_HTTPHEADER => array(
                'Content-Type: application/json'
            )
        ));

        $response = curl_exec($curl);
        curl_close($curl);
        $jsonResponse = json_decode($response);
        return $jsonResponse;
    }


    public function updateLead($dealId, $dealStatus){
        // Pego o ID do contato no HS e o CRM_ACCOUNT_ID
        $hsHelper = new hubspotHelper();
        $hsUserId = $hsHelper->hubspotGetUserByDeal($dealId);

        $wiserLeadId = null;
        $response_wsl = null;
        $update_success = false;
        if(!empty($hsUserId)){
            // Pego o wiserLeadId pelo hsUserId
            $aux = ORM::for_table('module_imobles_hubspot_contacts')->where('hs_object_id',$hsUserId)->find_one();
            if(isset($aux->crm_account_id)){
                $update_success = true;
                $aux = ORM::for_table('module_imobles_leads_wiserleads_contacts')
                    ->where('crm_account_id',$aux->crm_account_id)
                    ->order_by_desc('id')
                    ->find_one();
                if(isset($aux->wiserlead_id)){
                    $update_success = true;
                    $wiserLeadId = $aux->wiserlead_id;
                    switch($dealStatus){
                        case 'open':
                            $id_status = 2;
                        break;
                        case 'closed':
                            $id_status = 4;
                        break;
                        case 'won':
                            $id_status = 3;
                        break;
                        default:
                            $id_status = null;
                        break;
                    }
                    
                    if($id_status == null){
                        return false;
                    }

                    $data = [
                            "token" => "856c44fe7710772e46eddde8fa6537e2e2cef6a1fc9fe23fb64f133d17508f77",
                            "lead_id" => $wiserLeadId,
                            "vertical" => "imobles",
                            "id_status" => $id_status
                        ];
                    $curl = curl_init();
                    $data = json_encode($data);
                    curl_setopt_array($curl, array(
                        CURLOPT_URL => 'https://api.wiserleads.com.br/update',
                        CURLOPT_RETURNTRANSFER => true,
                        CURLOPT_ENCODING => '',
                        CURLOPT_MAXREDIRS => 10,
                        CURLOPT_TIMEOUT => 0,
                        CURLOPT_FOLLOWLOCATION => true,
                        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                        CURLOPT_CUSTOMREQUEST => 'POST',
                        CURLOPT_POSTFIELDS => $data,
                        CURLOPT_HTTPHEADER => array(
                            'Content-Type: application/json'
                        )
                    ));

                    $response_wsl = curl_exec($curl);
                    curl_close($curl);
                    $results = json_decode($response_wsl);
                    if(isset($results->lead_id) && !empty($results->lead_id)){
                        $lesdConParams = ORM::for_table('module_imobles_logs')->create();
                        $lesdConParams->created_at = date('Y-m-d H:i:s');
                        $lesdConParams->type = 'wiser_leads_update_success';
                        $lesdConParams->params = json_encode($results);
                        $lesdConParams->save();
                    } else {
                        $lesdConParams = ORM::for_table('module_imobles_logs')->create();
                        $lesdConParams->created_at = date('Y-m-d H:i:s');
                        $lesdConParams->type = 'wiser_leads_update_error';
                        $lesdConParams->params = $data;
                        $lesdConParams->save();
                    }
                }
            }
        }

        if($update_success === false){
            $data_aux = [
                "hsUserId" => $hsUserId,
                "wiserLeadId" => $wiserLeadId,
                "response_wsl" => $response_wsl
            ];
            $lesdConParams = ORM::for_table('module_imobles_logs')->create();
            $lesdConParams->created_at = date('Y-m-d H:i:s');
            $lesdConParams->type = 'wiser_leads_update_error';
            $lesdConParams->params = json_encode($data_aux);
            $lesdConParams->save();   
        }
    }
}

Anon7 - 2022
AnonSec Team