Plugin Directory

Changeset 2341588


Ignore:
Timestamp:
07/16/2020 12:52:21 PM (6 years ago)
Author:
ghostmonitor
Message:

AUTOMATED COMMIT, PLUGIN VERSION: 1.14.4

Location:
ghostmonitor
Files:
78 added
8 edited

Legend:

Unmodified
Added
Removed
  • ghostmonitor/trunk/config.json

    r2325070 r2341588  
    44    "settingsUrl": "https://api.recart.com/tracking/v2/settings/",
    55    "cdnUrl": "https://cdn.ghostmonitor.com",
    6     "version": "v1.14.3",
     6    "version": "v1.14.4",
    77    "logentriesToken": "d3695c56-67af-4c86-8c7d-26c6c252987b",
    88    "env": "production"
  • ghostmonitor/trunk/includes/ghostmonitor_helper/vendor/autoload.php

    r2325070 r2341588  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit90cbba8c754b606bb44f360586128748::getLoader();
     7return ComposerAutoloaderInit95c4e5c82fb7f6d3005eb8915ab001d1::getLoader();
  • ghostmonitor/trunk/includes/ghostmonitor_helper/vendor/composer/autoload_real.php

    r2325070 r2341588  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit90cbba8c754b606bb44f360586128748
     5class ComposerAutoloaderInit95c4e5c82fb7f6d3005eb8915ab001d1
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInit90cbba8c754b606bb44f360586128748', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit95c4e5c82fb7f6d3005eb8915ab001d1', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    27         spl_autoload_unregister(array('ComposerAutoloaderInit90cbba8c754b606bb44f360586128748', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit95c4e5c82fb7f6d3005eb8915ab001d1', 'loadClassLoader'));
    2828
    2929        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3131            require_once __DIR__ . '/autoload_static.php';
    3232
    33             call_user_func(\Composer\Autoload\ComposerStaticInit90cbba8c754b606bb44f360586128748::getInitializer($loader));
     33            call_user_func(\Composer\Autoload\ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1::getInitializer($loader));
    3434        } else {
    3535            $map = require __DIR__ . '/autoload_namespaces.php';
     
    5252
    5353        if ($useStaticLoader) {
    54             $includeFiles = Composer\Autoload\ComposerStaticInit90cbba8c754b606bb44f360586128748::$files;
     54            $includeFiles = Composer\Autoload\ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1::$files;
    5555        } else {
    5656            $includeFiles = require __DIR__ . '/autoload_files.php';
    5757        }
    5858        foreach ($includeFiles as $fileIdentifier => $file) {
    59             composerRequire90cbba8c754b606bb44f360586128748($fileIdentifier, $file);
     59            composerRequire95c4e5c82fb7f6d3005eb8915ab001d1($fileIdentifier, $file);
    6060        }
    6161
     
    6464}
    6565
    66 function composerRequire90cbba8c754b606bb44f360586128748($fileIdentifier, $file)
     66function composerRequire95c4e5c82fb7f6d3005eb8915ab001d1($fileIdentifier, $file)
    6767{
    6868    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • ghostmonitor/trunk/includes/ghostmonitor_helper/vendor/composer/autoload_static.php

    r2325070 r2341588  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit90cbba8c754b606bb44f360586128748
     7class ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1
    88{
    99    public static $files = array (
     
    4646    {
    4747        return \Closure::bind(function () use ($loader) {
    48             $loader->prefixLengthsPsr4 = ComposerStaticInit90cbba8c754b606bb44f360586128748::$prefixLengthsPsr4;
    49             $loader->prefixDirsPsr4 = ComposerStaticInit90cbba8c754b606bb44f360586128748::$prefixDirsPsr4;
    50             $loader->prefixesPsr0 = ComposerStaticInit90cbba8c754b606bb44f360586128748::$prefixesPsr0;
     48            $loader->prefixLengthsPsr4 = ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1::$prefixLengthsPsr4;
     49            $loader->prefixDirsPsr4 = ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1::$prefixDirsPsr4;
     50            $loader->prefixesPsr0 = ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1::$prefixesPsr0;
    5151
    5252        }, null, ClassLoader::class);
  • ghostmonitor/trunk/includes/ghostmonitor_helper/vendor/composer/installed.json

    r1974938 r2341588  
    4545    {
    4646        "name": "ghostmonitor/helper",
    47         "version": "v0.9.2",
    48         "version_normalized": "0.9.2.0",
     47        "version": "v0.9.3",
     48        "version_normalized": "0.9.3.0",
    4949        "source": {
    5050            "type": "git",
    5151            "url": "https://bitbucket.org/ghostmonitor/gm-plugin-helper.git",
    52             "reference": "98e615c8e545437de67635fdd98eb0e1c2ce993e"
     52            "reference": "d62743701fa00baa52668ea56c8250d8d6b16ee6"
    5353        },
    54         "time": "2016-05-06T12:56:32+00:00",
     54        "time": "2020-07-16T12:45:14+00:00",
    5555        "type": "library",
    5656        "installation-source": "source",
  • ghostmonitor/trunk/includes/ghostmonitor_helper/vendor/ghostmonitor/helper/ghostmonitor/Helper.php

    r1411703 r2341588  
    33use Assert\Assertion;
    44use Assert\AssertionFailedException;
    5 use Ghostmonitor\Logger;
    65
    76class Helper
     
    109    public $ghostmonitor_id;
    1110    public $api_url;
    12     public $api_base_url;
    1311    public $cdn_url;
    1412    public $url_params = array (
     
    2119    );
    2220
     21    // Log settings
     22    public $logger;
     23    public $logentries_token;
     24    public $log_path      = '';
     25    public $log_enabled   = true;
     26    public $local_logging = false;
     27    public $log_severity  = LOG_DEBUG;
     28
    2329    public $api_version = 'v1';
    24 
    25     private $logger;
    2630
    2731    public function __construct($ghostmonitor_id, $ghostmonitor_domain = false, $api_url = false, $cdn_url = false)
     
    3034        $this->ghostmonitor_id = $ghostmonitor_id;
    3135
    32         $this->api_base_url = ($api_url ?: 'https://tracking.ghostmonitor.com') . '/';
    33         $this->api_url = $this->api_base_url . $this->api_version . '/';
    34         $this->cdn_url = $cdn_url  ?: 'https://cdn.ghostmonitor.com';
    35 
    36         $this->logger = new Logger($this->ghostmonitor_id, $this->ghostmonitor_domain, $this->setGhostmonitorSessionId());
    37     }
    38 
    39     public function ghost_init($is_cart_empty = true, $additional_lines = '')
     36        $this->api_url = (!$api_url ? 'https://tracking.ghostmonitor.com' : $api_url) . '/' . $this->api_version . '/';
     37        $this->cdn_url = !$cdn_url  ? 'https://cdn.ghostmonitor.com' : $cdn_url;
     38    }
     39
     40    public function ghost_init($is_cart_empty = true)
    4041    {
    4142        $is_cart_empty = $is_cart_empty ? 'true' : 'false';
     
    4445
    4546        $js_domain = strlen($domain) < 2 ? '' : "_ghostmonitor.push(['setDomain', '" . $domain . "']);";
    46 
    47         $loginfo = $this->logger->getLoggingInfo();
    4847
    4948        return "
     
    5958                    s.type = 'text/javascript';
    6059                    s.async = true;
    61                     s.src = '" . $this->cdn_url . "/loader.js?'+g();
     60                    s.src = '" . $this->cdn_url . "/loader.js';
    6261                    var x = document.getElementsByTagName('script')[0];
    6362                    x.parentNode.insertBefore(s, x);
    64                     function g(){var t=new Date,e=t.getHours();return e=e%2===0?e:e-1,String(t.getFullYear())+t.getMonth()+t.getDate()+e};
    65                 })();$loginfo
     63                })();
    6664            </script>
    67             $additional_lines
    6865        ";
    6966    }
     
    7168    public function sendGhostData($ghostmonitorData, $version = 1)
    7269    {
    73         $this->logDebug('HELPER sendGhostData() VERSION: ' . $version);
    74 
    7570        if (false === $ghostmonitorData) {
    7671            return false;
    7772        }
    7873
    79         $this->validateData($ghostmonitorData);
     74        if (true !== $this->validateData($ghostmonitorData)) {
     75            return $this->validateData($ghostmonitorData);
     76        }
    8077
    8178        switch ($version) {
     
    9390    }
    9491
    95     public function sendConversionData($session_id = false)
    96     {
    97         $this->logDebug('HELPER sendConversionData()');
    98         $conversionData = $this->getConversionData($session_id);
    99 
    100         $this->postGmData($conversionData, $this->ghostmonitor_id . '/setconversion');
    101 
    102         return true;
    103     }
    104 
    105     public function sendShopData($data = array())
    106     {
    107         if (!$this->ghostmonitor_id) {
    108             $data['site_url'] = $this->ghostmonitor_domain;
    109         } else {
    110             $data['ghostmonitor_site_id'] = $this->ghostmonitor_id;
    111         }
    112 
    113         $this->postGmData($data, 'install_info');
    114     }
    115 
    116     public function setGhostmonitorSessionId()
    117     {
    118         // TODO: debug logging error
    119         // $this->logError('XYZ') results in Call to a member function logError() on null
    120         return isset($_COOKIE['ghostmonitor_session_id']) ? $_COOKIE['ghostmonitor_session_id'] : false;
    121     }
    122    
    12392    public function getConversionData($session_id = false)
    12493    {
     
    142111            $exceptions = array($ex->getValue(), $ex->getConstraints(), $ex->getMessage());
    143112            $this->logError($exceptions);
    144         }
    145 
    146         $this->logDebug(array('HELPER getConversionData()', 'CONVERSION DATA', $conversionData));
     113            return false;
     114        }
    147115
    148116        return $conversionData;
     117    }
     118
     119    public function sendConversionData($session_id = false)
     120    {
     121        $conversionData = $this->getConversionData($session_id);
     122
     123        $this->postGmData($conversionData, $this->ghostmonitor_id . '/setconversion');
     124
     125        return true;
     126    }
     127
     128    public function sendShopData($data = array())
     129    {
     130        if (!$this->ghostmonitor_id) {
     131            $data['site_url'] = $this->ghostmonitor_domain;
     132        } else {
     133            $data['ghostmonitor_site_id'] = $this->ghostmonitor_id;
     134        }
     135
     136        $this->postGmData($data, 'install_info');
    149137    }
    150138
     
    160148            'discount_name' => 'Ghostmonitor Discount',
    161149        );
     150    }
     151
     152    public function setGhostmonitorSessionId()
     153    {
     154        return isset($_COOKIE['ghostmonitor_session_id']) ? $_COOKIE['ghostmonitor_session_id'] : false;
    162155    }
    163156
     
    225218        } catch (AssertionFailedException $ex) {
    226219            $exceptions = array($ex->getValue(), $ex->getConstraints(), $ex->getMessage());
    227             $this->logError(array('HELPER validateData() failed', $exceptions));
    228             return false;
    229         }
    230 
    231         $this->logDebug('HELPER validateData() successful');
     220            $this->logError($exceptions);
     221            return false;
     222        }
    232223
    233224        return true;
    234225    }
    235    
    236     public function testHTTP()
    237     {
    238         $result = $this->postGmData(array(), $this->api_base_url . 'version', false, false);
    239         error_log('test http: ' . var_export($result, true));
    240         return $result;
     226
     227    public function switchToLocalLogging($log_path)
     228    {
     229        $this->local_logging = true;
     230        $this->log_path = $log_path;
     231    }
     232
     233    public function logError($line)
     234    {
     235        $this->log($line);
     236    }
     237
     238    public function log($line, $severity = 'Error')
     239    {
     240        if (false === $this->log_enabled) {
     241            return false;
     242        }
     243
     244        if ($this->local_logging || empty($this->logentries_token) || false === class_exists('\Logentries\LeLogger')) {
     245            $this->logLocal($line);
     246            return false;
     247        }
     248
     249        $line     = $this->createLogLine($line);
     250        $severity = ucfirst(strtolower($severity));
     251        $logger   = new \Logentries\LeLogger($this->logentries_token, $this->log_severity);
     252
     253        if (!method_exists($logger, $severity)) {
     254            return false;
     255        }
     256
     257        call_user_func_array(array($logger, $severity), array($line));
     258    }
     259
     260    private function logLocal($line)
     261    {
     262        if ('' === $this->log_path) {
     263            return false;
     264        }
     265
     266        $log_file_name = is_dir($this->log_path) ? join('/', array(trim($this->log_path, '/'), 'log.txt')) : $this->log_path;
     267
     268        file_put_contents($log_file_name, $this->createLogLine($line, true) . PHP_EOL, FILE_APPEND);
     269    }
     270
     271    private function createLogLine($line, $timestamp = false)
     272    {
     273        $gm_id     = empty($this->ghostmonitor_id) ? 'empty site_id' : $this->ghostmonitor_id;
     274        $gm_domain = empty($this->ghostmonitor_domain) ? 'empty domain' : $this->ghostmonitor_domain;
     275        $line      = '[[ SITE_ID: ' . $gm_id . ' | DOMAIN: ' . $gm_domain . ' ]] MESSAGE: ' . var_export($line, true);
     276
     277        if ($timestamp) {
     278            $line = date(DATE_ATOM) . ' ' . $line;
     279        }
     280
     281        return $line;
    241282    }
    242283
     
    291332    }
    292333
    293     private function postGmData($data, $api_path, $json = false, $post = true)
    294     {
    295         $content_type = $json ? 'Content-type: application/json' : 'Content-type: application/x-www-form-urlencoded';
    296 
    297         $url = strpos($api_path, 'http') === 0 ? $api_path : $this->api_url . $api_path;
    298 
    299         error_log('POST URL: ' . $url);
    300 
    301         $post_data = $json ? $data : http_build_query((array)$data);
    302        
    303         // check if curl is loaded and curl_exec function is enabled
    304         $send_with_curl = extension_loaded('curl') && strpos(ini_get('disable_functions'), 'curl_exec') === false;
    305 
    306         $this->logDebug(array(
    307             'HELPER postGmData() before sending',
    308             'METHOD: ' . ($send_with_curl ? 'CURL' : 'FILE_GET_CONTENTS'),
    309             'POST DATA', $post_data,
    310             'POST URL', $url
    311         ));
    312 
    313         if ($send_with_curl) {
    314 
     334    private function postGmData($data, $api_path, $json = false)
     335    {
     336        $headers = array(
     337            $json ? 'Content-type: application/json' : 'Content-type: application/x-www-form-urlencoded',
     338            'X-WP-Version: ' . get_bloginfo( 'version' ),
     339            'X-PHP-Version: ' . phpversion()
     340        );
     341
     342        if (defined('WC_VERSION')) {
     343            array_push ( $headers, 'X-WC-Version: ' . WC_VERSION );
     344        }
     345
     346        $post_url = $this->api_url .  $api_path;
     347
     348        $post_data = $json ? $data : http_build_query($data);
     349
     350        if (extension_loaded('curl')) {
    315351            $ch = curl_init();
    316352
    317             // TODO: URL validáció!
    318        
    319             // redefine constant if not exists for PHP 5.3 compatibility
     353            # TODO: URL validáció!
     354
     355            # redefine constant if not exists for PHP 5.3 compatibility
    320356            if (!defined('CURLOPT_TIMEOUT_MS')) {
    321357                define('CURLOPT_TIMEOUT_MS', 156);
    322358            }
    323359
    324             // set curl opts for GET request
    325             $opts = array(
    326                 CURLOPT_URL => $url,
    327                 CURLOPT_RETURNTRANSFER => true,
    328                 CURLOPT_TIMEOUT_MS => 5000,
    329             );
    330 
    331             // if post is true configure curl for post req
    332             if ($post === true) {
    333                 $opts = $opts + array(
    334                     CURLOPT_POST       => $post,
    335                     CURLOPT_POSTFIELDS => $post_data,
    336                     CURLOPT_NOSIGNAL   => 1,
    337                     CURLOPT_HTTPHEADER => array($content_type)
    338                 );
    339             }
    340 
    341             curl_setopt_array($ch, $opts);
    342 
    343             $result = curl_exec($ch);
     360            curl_setopt($ch, CURLOPT_URL, $post_url);
     361            curl_setopt($ch, CURLOPT_POST, true);
     362            curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
     363            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     364            curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
     365            curl_setopt($ch, CURLOPT_TIMEOUT_MS, 5000);
     366            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     367
     368            curl_exec($ch);
    344369            $curl_errno = curl_errno($ch);
    345370            $curl_error = curl_error($ch);
    346             $curl_info  = curl_getinfo($ch);
    347371            curl_close($ch);
    348372
    349             $this->logDebug(array('CURL INFO', $curl_info));
    350 
    351373            if ($curl_errno != "" || $curl_error != "") {
    352                 $this->logError('CURL ERROR: ' . $curl_errno . ' - ' . $curl_error);
    353                 return false;
     374                $error_str = 'CURL ERROR: ' . $curl_errno . ' - ' . $curl_error;
     375                $this->logError($error_str);
     376                return $error_str;
    354377            }
    355378
    356             return $result;
    357         }
    358        
    359         if (ini_get('allow_url_fopen') == 0) {
    360             return false;
    361         }
    362 
    363         $options = array('http' => array (
    364             'method'  => $post ? 'POST' : 'GET',
    365             'timeout' => (float)5,
    366             'ignore_errors' => true,
    367             'protocol_version' => (float)1.1,
    368         ));
    369 
    370         if ($post === true) {
    371             $options['http'] = $options['http'] + array(
    372                 'header'  => $content_type,
    373                 'content' => $post_data
    374             );
    375         }
    376 
    377         $context = stream_context_create($options);
    378         $result  = file_get_contents($url, false, $context);
    379 
    380         $this->logDebug(array('FILE_GET_CONTENTS RESULT', $result));
     379            return true;
     380        }
     381
     382        $options = array('http' =>
     383            array (
     384                'method'  => 'POST',
     385                'header'  => $headers,
     386                'timeout' => (float)5,
     387                'ignore_errors' => true,
     388                'protocol_version' => (float)1.0,
     389                'content' => $post_data,
     390            )
     391        );
     392
     393        $context  = stream_context_create($options);
     394
     395        $result = file_get_contents($post_url, false, $context);
    381396
    382397        if (false === $result) {
    383398            $this->logError(array('FILE_GET_CONTENTS_ERROR','last_error' => error_get_last()));
    384             return false;
    385         }
    386 
    387         return $result;
    388     }
    389 
    390     public function getInlineGMScripts($ghostmonitorData)
    391     {
    392         if (empty($ghostmonitorData['setCartData']) || empty($ghostmonitorData['setCartItem'])) {
    393             return false;
    394         }
    395         $script = '<script type=\'text/javascript\'>' . PHP_EOL;
    396 
    397         $gm_push = '_ghostmonitor.push([%s, %s]);' . PHP_EOL;
    398 
    399         // add setCartData
    400         unset($ghostmonitorData['setCartData']['session_id']);
    401 
    402         $script .= sprintf($gm_push, '\'setCartData\'', json_encode($ghostmonitorData['setCartData']));
    403 
    404         // add setCartItems
    405         foreach ($ghostmonitorData['setCartItem'] as $cartItem) {
    406             unset($cartItem['session_id']);
    407 
    408             $script .= sprintf($gm_push, '\'setCartItem\'', json_encode($cartItem));
    409         }
    410 
    411         $script = $script . '</script>' . PHP_EOL;
    412 
    413         return $script;
    414     }
    415 
    416     // Helper functions for logging
    417     public function logDebug($line)
    418     {
    419         $this->logger->logDebug($line);
    420     }
    421 
    422     // Helper functions for logging
    423     public function logError($line)
    424     {
    425         $this->logger->logError($line);
    426     }
    427 
    428     public function log($line, $severity = 'Error')
    429     {
    430         $this->logger->log($line, $severity);
    431     }
    432 
    433     public function setLogPath($path = '')
    434     {
    435         $this->logger->log_path = $path;
    436     }
    437 
    438     public function setLogentriesToken($path = '')
    439     {
    440         $this->logger->logentries_token = $path;
    441     }
    442 
    443     public function isLoggingEnabled()
    444     {
    445         return $this->logger->isLoggingEnabled();
     399        }
     400
     401        return $result !== false ? true : false;
    446402    }
    447403}
  • ghostmonitor/trunk/readme.txt

    r2325070 r2341588  
    44Requires at least: 3.9
    55Tested up to: 5.3.2
    6 Stable tag: 1.14.3
     6Stable tag: 1.14.4
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • ghostmonitor/trunk/woocommerce-ghostmonitor.php

    r2325070 r2341588  
    66 * Author: Ghostmonitor INC
    77 * Author URI: http://www.recart.com
    8  * Version: v1.14.3
     8 * Version: v1.14.4
    99 */
    1010
     
    4444        global $wp_version;
    4545
    46         $version = 'v1.14.3';
     46        $version = 'v1.14.4';
    4747
    4848        $discount_enabled = get_option('woocommerce_enable_coupons') === 'yes' ? 'true' : 'false';
Note: See TracChangeset for help on using the changeset viewer.