Changeset 2341588
- Timestamp:
- 07/16/2020 12:52:21 PM (6 years ago)
- Location:
- ghostmonitor
- Files:
-
- 78 added
- 8 edited
-
tags/1.14.4 (added)
-
tags/1.14.4/assets (added)
-
tags/1.14.4/assets/js (added)
-
tags/1.14.4/assets/js/ghostmonitor_messenger_widget.js (added)
-
tags/1.14.4/assets/js/ghostmonitor_push.js (added)
-
tags/1.14.4/config.json (added)
-
tags/1.14.4/includes (added)
-
tags/1.14.4/includes/class-wc-ghostmonitor-api.php (added)
-
tags/1.14.4/includes/class-wc-ghostmonitor.php (added)
-
tags/1.14.4/includes/ghostmonitor_api (added)
-
tags/1.14.4/includes/ghostmonitor_api/ghost-api.php (added)
-
tags/1.14.4/includes/ghostmonitor_api/src (added)
-
tags/1.14.4/includes/ghostmonitor_api/src/controller (added)
-
tags/1.14.4/includes/ghostmonitor_api/src/controller/class-base-controller.php (added)
-
tags/1.14.4/includes/ghostmonitor_api/src/controller/class-stat-controller.php (added)
-
tags/1.14.4/includes/ghostmonitor_api/src/model (added)
-
tags/1.14.4/includes/ghostmonitor_api/src/model/class-order-model.php (added)
-
tags/1.14.4/includes/ghostmonitor_api/src/utils (added)
-
tags/1.14.4/includes/ghostmonitor_api/src/utils/request (added)
-
tags/1.14.4/includes/ghostmonitor_api/src/utils/request/class-request-interface.php (added)
-
tags/1.14.4/includes/ghostmonitor_api/src/utils/request/class-request.php (added)
-
tags/1.14.4/includes/ghostmonitor_api/src/utils/response (added)
-
tags/1.14.4/includes/ghostmonitor_api/src/utils/response/class-response.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/autoload.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/composer (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/composer/ClassLoader.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/composer/LICENSE (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/composer/autoload_classmap.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/composer/autoload_files.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/composer/autoload_namespaces.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/composer/autoload_psr4.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/composer/autoload_real.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/composer/autoload_static.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/composer/installed.json (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/.gitignore (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/.travis.yml (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/LICENSE (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/README.md (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/bin (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/bin/generate_method_docs.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/composer.json (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/lib (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/lib/Assert (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/lib/Assert/Assertion.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/lib/Assert/AssertionChain.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/lib/Assert/AssertionFailedException.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/lib/Assert/InvalidArgumentException.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/lib/Assert/LazyAssertion.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/lib/Assert/LazyAssertionException.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/lib/Assert/functions.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/phpunit.xml.dist (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/tests (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/tests/Assert (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/tests/Assert/Tests (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/tests/Assert/Tests/AssertTest.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/tests/Assert/Tests/AssertionChainTest.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/tests/Assert/Tests/LazyAssertionTest.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/assert/tests/bootstrap.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/helper (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/helper/.gitignore (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/helper/composer.json (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/helper/ghostmonitor (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/helper/ghostmonitor/Helper.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/logentries (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/logentries/.gitignore (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/logentries/.travis.yml (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/logentries/LeLogger.php (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/logentries/README.md (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/logentries/composer.json (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/logentries/phpunit.xml (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/logentries/unit_tests (added)
-
tags/1.14.4/includes/ghostmonitor_helper/vendor/ghostmonitor/logentries/unit_tests/LeLoggerTests.php (added)
-
tags/1.14.4/readme.txt (added)
-
tags/1.14.4/woocommerce-ghostmonitor.php (added)
-
trunk/config.json (modified) (1 diff)
-
trunk/includes/ghostmonitor_helper/vendor/autoload.php (modified) (1 diff)
-
trunk/includes/ghostmonitor_helper/vendor/composer/autoload_real.php (modified) (5 diffs)
-
trunk/includes/ghostmonitor_helper/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/includes/ghostmonitor_helper/vendor/composer/installed.json (modified) (1 diff)
-
trunk/includes/ghostmonitor_helper/vendor/ghostmonitor/helper/ghostmonitor/Helper.php (modified) (12 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/woocommerce-ghostmonitor.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ghostmonitor/trunk/config.json
r2325070 r2341588 4 4 "settingsUrl": "https://api.recart.com/tracking/v2/settings/", 5 5 "cdnUrl": "https://cdn.ghostmonitor.com", 6 "version": "v1.14. 3",6 "version": "v1.14.4", 7 7 "logentriesToken": "d3695c56-67af-4c86-8c7d-26c6c252987b", 8 8 "env": "production" -
ghostmonitor/trunk/includes/ghostmonitor_helper/vendor/autoload.php
r2325070 r2341588 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit9 0cbba8c754b606bb44f360586128748::getLoader();7 return ComposerAutoloaderInit95c4e5c82fb7f6d3005eb8915ab001d1::getLoader(); -
ghostmonitor/trunk/includes/ghostmonitor_helper/vendor/composer/autoload_real.php
r2325070 r2341588 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit9 0cbba8c754b606bb44f3605861287485 class ComposerAutoloaderInit95c4e5c82fb7f6d3005eb8915ab001d1 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit9 0cbba8c754b606bb44f360586128748', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInit95c4e5c82fb7f6d3005eb8915ab001d1', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 27 spl_autoload_unregister(array('ComposerAutoloaderInit9 0cbba8c754b606bb44f360586128748', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit95c4e5c82fb7f6d3005eb8915ab001d1', 'loadClassLoader')); 28 28 29 29 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 31 31 require_once __DIR__ . '/autoload_static.php'; 32 32 33 call_user_func(\Composer\Autoload\ComposerStaticInit9 0cbba8c754b606bb44f360586128748::getInitializer($loader));33 call_user_func(\Composer\Autoload\ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1::getInitializer($loader)); 34 34 } else { 35 35 $map = require __DIR__ . '/autoload_namespaces.php'; … … 52 52 53 53 if ($useStaticLoader) { 54 $includeFiles = Composer\Autoload\ComposerStaticInit9 0cbba8c754b606bb44f360586128748::$files;54 $includeFiles = Composer\Autoload\ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1::$files; 55 55 } else { 56 56 $includeFiles = require __DIR__ . '/autoload_files.php'; 57 57 } 58 58 foreach ($includeFiles as $fileIdentifier => $file) { 59 composerRequire9 0cbba8c754b606bb44f360586128748($fileIdentifier, $file);59 composerRequire95c4e5c82fb7f6d3005eb8915ab001d1($fileIdentifier, $file); 60 60 } 61 61 … … 64 64 } 65 65 66 function composerRequire9 0cbba8c754b606bb44f360586128748($fileIdentifier, $file)66 function composerRequire95c4e5c82fb7f6d3005eb8915ab001d1($fileIdentifier, $file) 67 67 { 68 68 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
ghostmonitor/trunk/includes/ghostmonitor_helper/vendor/composer/autoload_static.php
r2325070 r2341588 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit9 0cbba8c754b606bb44f3605861287487 class ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1 8 8 { 9 9 public static $files = array ( … … 46 46 { 47 47 return \Closure::bind(function () use ($loader) { 48 $loader->prefixLengthsPsr4 = ComposerStaticInit9 0cbba8c754b606bb44f360586128748::$prefixLengthsPsr4;49 $loader->prefixDirsPsr4 = ComposerStaticInit9 0cbba8c754b606bb44f360586128748::$prefixDirsPsr4;50 $loader->prefixesPsr0 = ComposerStaticInit9 0cbba8c754b606bb44f360586128748::$prefixesPsr0;48 $loader->prefixLengthsPsr4 = ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1::$prefixLengthsPsr4; 49 $loader->prefixDirsPsr4 = ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1::$prefixDirsPsr4; 50 $loader->prefixesPsr0 = ComposerStaticInit95c4e5c82fb7f6d3005eb8915ab001d1::$prefixesPsr0; 51 51 52 52 }, null, ClassLoader::class); -
ghostmonitor/trunk/includes/ghostmonitor_helper/vendor/composer/installed.json
r1974938 r2341588 45 45 { 46 46 "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", 49 49 "source": { 50 50 "type": "git", 51 51 "url": "https://bitbucket.org/ghostmonitor/gm-plugin-helper.git", 52 "reference": " 98e615c8e545437de67635fdd98eb0e1c2ce993e"52 "reference": "d62743701fa00baa52668ea56c8250d8d6b16ee6" 53 53 }, 54 "time": "20 16-05-06T12:56:32+00:00",54 "time": "2020-07-16T12:45:14+00:00", 55 55 "type": "library", 56 56 "installation-source": "source", -
ghostmonitor/trunk/includes/ghostmonitor_helper/vendor/ghostmonitor/helper/ghostmonitor/Helper.php
r1411703 r2341588 3 3 use Assert\Assertion; 4 4 use Assert\AssertionFailedException; 5 use Ghostmonitor\Logger;6 5 7 6 class Helper … … 10 9 public $ghostmonitor_id; 11 10 public $api_url; 12 public $api_base_url;13 11 public $cdn_url; 14 12 public $url_params = array ( … … 21 19 ); 22 20 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 23 29 public $api_version = 'v1'; 24 25 private $logger;26 30 27 31 public function __construct($ghostmonitor_id, $ghostmonitor_domain = false, $api_url = false, $cdn_url = false) … … 30 34 $this->ghostmonitor_id = $ghostmonitor_id; 31 35 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) 40 41 { 41 42 $is_cart_empty = $is_cart_empty ? 'true' : 'false'; … … 44 45 45 46 $js_domain = strlen($domain) < 2 ? '' : "_ghostmonitor.push(['setDomain', '" . $domain . "']);"; 46 47 $loginfo = $this->logger->getLoggingInfo();48 47 49 48 return " … … 59 58 s.type = 'text/javascript'; 60 59 s.async = true; 61 s.src = '" . $this->cdn_url . "/loader.js ?'+g();60 s.src = '" . $this->cdn_url . "/loader.js'; 62 61 var x = document.getElementsByTagName('script')[0]; 63 62 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 })(); 66 64 </script> 67 $additional_lines68 65 "; 69 66 } … … 71 68 public function sendGhostData($ghostmonitorData, $version = 1) 72 69 { 73 $this->logDebug('HELPER sendGhostData() VERSION: ' . $version);74 75 70 if (false === $ghostmonitorData) { 76 71 return false; 77 72 } 78 73 79 $this->validateData($ghostmonitorData); 74 if (true !== $this->validateData($ghostmonitorData)) { 75 return $this->validateData($ghostmonitorData); 76 } 80 77 81 78 switch ($version) { … … 93 90 } 94 91 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 error119 // $this->logError('XYZ') results in Call to a member function logError() on null120 return isset($_COOKIE['ghostmonitor_session_id']) ? $_COOKIE['ghostmonitor_session_id'] : false;121 }122 123 92 public function getConversionData($session_id = false) 124 93 { … … 142 111 $exceptions = array($ex->getValue(), $ex->getConstraints(), $ex->getMessage()); 143 112 $this->logError($exceptions); 144 } 145 146 $this->logDebug(array('HELPER getConversionData()', 'CONVERSION DATA', $conversionData)); 113 return false; 114 } 147 115 148 116 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'); 149 137 } 150 138 … … 160 148 'discount_name' => 'Ghostmonitor Discount', 161 149 ); 150 } 151 152 public function setGhostmonitorSessionId() 153 { 154 return isset($_COOKIE['ghostmonitor_session_id']) ? $_COOKIE['ghostmonitor_session_id'] : false; 162 155 } 163 156 … … 225 218 } catch (AssertionFailedException $ex) { 226 219 $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 } 232 223 233 224 return true; 234 225 } 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; 241 282 } 242 283 … … 291 332 } 292 333 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')) { 315 351 $ch = curl_init(); 316 352 317 //TODO: URL validáció!318 319 //redefine constant if not exists for PHP 5.3 compatibility353 # TODO: URL validáció! 354 355 # redefine constant if not exists for PHP 5.3 compatibility 320 356 if (!defined('CURLOPT_TIMEOUT_MS')) { 321 357 define('CURLOPT_TIMEOUT_MS', 156); 322 358 } 323 359 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); 344 369 $curl_errno = curl_errno($ch); 345 370 $curl_error = curl_error($ch); 346 $curl_info = curl_getinfo($ch);347 371 curl_close($ch); 348 372 349 $this->logDebug(array('CURL INFO', $curl_info));350 351 373 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; 354 377 } 355 378 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); 381 396 382 397 if (false === $result) { 383 398 $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; 446 402 } 447 403 } -
ghostmonitor/trunk/readme.txt
r2325070 r2341588 4 4 Requires at least: 3.9 5 5 Tested up to: 5.3.2 6 Stable tag: 1.14. 36 Stable tag: 1.14.4 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
ghostmonitor/trunk/woocommerce-ghostmonitor.php
r2325070 r2341588 6 6 * Author: Ghostmonitor INC 7 7 * Author URI: http://www.recart.com 8 * Version: v1.14. 38 * Version: v1.14.4 9 9 */ 10 10 … … 44 44 global $wp_version; 45 45 46 $version = 'v1.14. 3';46 $version = 'v1.14.4'; 47 47 48 48 $discount_enabled = get_option('woocommerce_enable_coupons') === 'yes' ? 'true' : 'false';
Note: See TracChangeset
for help on using the changeset viewer.