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/  Your IP : 172.18.0.1   [ Reverse IP ]
Web Server : Apache/2.4.38 (Debian)
System : Linux a1822d00732a 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 x86_64
User : www-data ( 33)
PHP Version : 7.1.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Domains : 0 Domains
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/1701/cwd/html/app/model/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /proc/1701/cwd/html/app/model/ecoMail.php
<?php
/**
 * Created by PhpStorm.
 * User: Martin Ferst
 * Date: 30.05.2018
 * Time: 4:40
 */

namespace Promoteus;

use Nette;
use Nette\Database\Context;
use Tracy\Debugger;

class ecoMail extends Nette\Application\UI\Presenter
{
    /** @var Context @inject */
    public $db;
    /** @var ClientRepository @inject */
    public $clientRep;
    /** @var ClientNewsletterGroupRepository @inject */
    public $clientNewsGroupRep;

    private $type = array("key: 5aef4d56b46695aef4d56b470e", "Content-Type:application/json");
    private $httpHeader = array("key: 5aef4d56b46695aef4d56b470e");

    public function subscribeRequest($email, $values, $listId)
    {
        /** @var ClientRepository $clientRep */
        $clientRep = $this->context->getService("clientRepository");
        try{
            $clientRep->updateNewsletter($email, $values, $listId);
        }catch (\Exception $e){
            Debugger::log($e,"ecomail_webhook");
        }

    }

    public function updateLinks()
    {
        $this->clientRep->updateEcomailGroupsByNewsletters();
    }


    public function updateEcomailData()
    {
        echo "updating links\n";
        $this->updateLinks(); // aktualizace linků v DB
        echo "loading Ecomail groups\n";
        $groups = $this->clientNewsGroupRep->getEcomailGroups(); // načtení NL skupin propojených s Ecomailem

        foreach ($groups as $group) {
            echo "updating group $group\n";
            $ecoUsers = $this->getAllSubscribersByList($group);
            $dbUsers = $this->getDbUsersByGroup($group);

            if(is_array($ecoUsers) && is_array($dbUsers) && count($ecoUsers) > 0 && count($dbUsers) > 0) {
                // remove all ecomail subscribers not present in system DB
                $unsubArray = $this->prepareDbEcoSubsData($ecoUsers,$dbUsers);
                foreach ($unsubArray as $client){
                    echo "unsubscribing user $client from group $group\n";
                    $this->unsubscribeSubscriber($client, $group);
                }
            }

            if(is_array($dbUsers) && count($dbUsers) > 0) {
                foreach ($dbUsers as $client) {
                    echo "subscribing user " . $client['email'] . " to group $group\n";
                    $this->addSubscriber($group, $client);
                }
            }
        }
    }

    /**
     * @param array $eco
     * @param array $db
     * @return array
     */
    public function prepareDbEcoSubsData(array $eco, array $db){
        $dbTmp = array();
        $ecoTmp = array();
        $unsubArray = array();
        foreach($db as $aV){
            $dbTmp[] = $aV['email'];
        }
        foreach($eco as $aV){
            $ecoTmp[] = $aV['email'];
        }
        foreach ($ecoTmp as $email){
            if(!in_array($email, $dbTmp)){
                $unsubArray[] = $email;
            }
        }
        return $unsubArray;
    }

    /**
     * @param $id
     * @return bool|Nette\Database\Table\ActiveRow
     */
    public function getUnsubscribeHashById($id){
        $hash = $this->db->
        table("client_gdpr")->
        select("unsubscribe_hash")->
        where("client_id", $id)->
        fetch();
        if($hash){
            return $hash;
        }else{
            return false;
        }
    }

    /**
     * @param $group
     * @return array
     */
    public function getDbUsersByGroup($group){
        $a = $this->clientRep->findClientByEcomailGroupId($group);
        $dbUsers = array();
        foreach ($a as $row) {

            $dbUsers[$row->email] = array(
                "email" => $row->email,
                "country" => $row->country,
                "name" => $row->name,
                "surname" => $row->surname,
                "hash" => $this->getUnsubscribeHashById($row->id)["unsubscribe_hash"],
                "salutation" => $row->salutation,
                "bonus_points" => ($row->bonus_program == 1)?$row->bonus_points:0
            );
        }
        return $dbUsers;
    }

    /**
     * @param $id
     * @return array
     */
    public function getAllSubscribersByList($id)
    {
        $ecoUsers = array();
        $a = json_decode($this->getSubscribersByList($id));
        foreach ($a->data as $row) {
            $ecoUsers[$row->email] = array(
                "email" => $row->email,
                "name" => $row->subscriber->name,
                "surname" => $row->subscriber->surname,
                "hash" => $row->custom_fields->HASH,
                "salutation" => $row->custom_fields->SALUTATION,
                "bonus_points" => isset($row->custom_fields->BONUS_POINTS) ? $row->custom_fields->BONUS_POINTS : null
            );
        }
        $url = $a->next_page_url;
        for ($b = 1; $b <= $a->last_page; $b++) {
            $c = json_decode($this->getSubscribersByList($id, $url));
            foreach ($c->data as $row) {
                $ecoUsers[$row->email] = array(
                    "email" => $row->email,
                    "name" => $row->subscriber->name,
                    "surname" => $row->subscriber->surname,
                    "hash" => $row->custom_fields->HASH,
                    "salutation" => $row->custom_fields->SALUTATION,
                    "bonus_points" => isset($row->custom_fields->BONUS_POINTS) ? $row->custom_fields->BONUS_POINTS : null
                );
            }
            $url = $c->next_page_url;
        }
        return $ecoUsers;
    }

    /**
     * @param $id
     * @param null $url
     * @return mixed
     */
    public function getSubscribersByList($id, $url = null)
    {
        $ch = curl_init();
        if ($url == null) {
            curl_setopt($ch, CURLOPT_URL, "http://api2.ecomailapp.cz/lists/" . $id . "/subscribers");
        } else {
            curl_setopt($ch, CURLOPT_URL, $url);
        }
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $this->httpHeader);
        $response = curl_exec($ch);
        curl_close($ch);
        return $response;
    }

    /**
     * @param $email
     * @param $id
     * @return mixed
     */
    public function unsubscribeSubscriber($email, $id){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "http://api2.ecomailapp.cz/lists/".$id."/unsubscribe");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
        curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"email\": \"".$email."\"}");
        curl_setopt($ch, CURLOPT_HTTPHEADER, $this->type);
        $response = curl_exec($ch);
        curl_close($ch);
        return $response;
    }

    /**
     * @param $id
     * @param $data
     * $data (email,name,surname,hash,salutation)
     * @return mixed
     */
    public function addSubscriber($id, $data){
        $ch = curl_init();
        $hash = "";
        $name = "";
        $surname = "";
        $email = "";
        $bonusPoints = "";
        curl_setopt($ch, CURLOPT_URL, "http://api2.ecomailapp.cz/lists/".$id."/subscribe");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        if(!strlen($data["email"]) == 0){
            $email = "\"email\": \"".$data["email"]."\"";
        }
        if(isset($data["hash"]) AND strlen($data["hash"]) > 0){
            $hash = "\"HASH\": \"".$data["hash"]."\", ";
        }
        if(isset($data["bonus_points"])){
            $bonusPoints = "\"BONUS_POINTS\": ".$data["bonus_points"].", ";
        }
        if(isset($data["salutation"]) AND strlen($data["salutation"]) > 0){
            $salutation = "\"SALUTATION\": \"".$data["salutation"]."\"";
        }else{
            switch ($data['country']) {
                case 56:
                    $tmp = 'Vážení zákazníci';
                    break;
                case 83:
                    $tmp = 'Sehr geehrte Kunden';
                    break;
                default:
                    $tmp = 'Dear Sir / Madam';
            }
            $salutation = "\"SALUTATION\": \"".$tmp."\"";
        }
        if(isset($data["name"]) AND strlen($data["name"]) > 0){
            $name = "\"name\": \"".$data["name"]."\", ";
        }
        if(isset($data["surname"]) AND strlen($data["surname"]) > 0){
            $surname = "\"surname\": \"".$data["surname"]."\", ";
        }
        $body = "{".$email.", \"subscriber_data\": { ".$name.$surname.$email.", \"custom_fields\": {".$hash.$bonusPoints.$salutation."}},\"update_existing\": true,\"resubscribe\": true}";
        curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $this->type);
        $response = curl_exec($ch);
        curl_close($ch);
        return $response;
    }

    public function showEcomailClientDiff($hash){
        //md5 testicek
        if("00E04AED28E2157955BF1734EA66E92A" == $hash){
            $groups = $this->clientNewsGroupRep->getEcomailGroups();
            $return = [];
            foreach ($groups as $group){
                $ecoUsers = $this->getAllSubscribersByList($group);
                //get array of all subscribers form database by ecomail group
                $dbUsers = $this->getDbUsersByGroup($group);
                $usnubArray = $this->prepareDbEcoDiffData($ecoUsers,$dbUsers);
                $return[]["group"] = $group;
                $return[]["unsub"] = $usnubArray;
            }
            return $return;
        }
        return false;
    }

    public function prepareDbEcoDiffData(array $eco, array $db){
        $dbTmp = array();
        $ecoTmp = array();
        $ecoToDb = array();
        $dbToEco = array();
        foreach($db as $aV){
            $dbTmp[] = $aV['email'];
        }
        foreach($eco as $aV){
            $ecoTmp[] = $aV['email'];
        }
        foreach ($ecoTmp as $email){
            if(!in_array($email, $dbTmp)){
                $ecoToDb[] = $email;
            }
        }
        foreach ($dbTmp as $email){
            if(!in_array($email, $ecoTmp)){
                $dbToEco[] = $email;
            }
        }
        $finArray = array("ecoToDb" => $ecoToDb, "dbToEco" => $dbToEco);
        return $finArray;
    }
}

Anon7 - 2022
AnonSec Team