Example #1
1
 /**
  * Post-save handling.
  *
  * Note: not run when importing
  */
 protected function _postSave()
 {
     parent::_postSave();
     if ($this->isInsert() && !empty(XenForo_Application::getOptions()->dpAnalyticsEvents['report']) && !empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) {
         if (XenForo_Application::isRegistered('fc')) {
             if (XenForo_Application::getFc()->route()->getAction() == 'report') {
                 $customFields = XenForo_Visitor::getInstance()->get('customFields');
                 $label = null;
                 $reportModel = $this->_getReportModel();
                 if ($report = $reportModel->getReportById($this->get('report_id'))) {
                     if ($reportHandler = Xenforo_Model::create('XenForo_Model_Report')->getReportHandler($report['content_type'])) {
                         $label = (string) $reportHandler->getContentTitle($report, unserialize($report['content_info']));
                     }
                 }
                 DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, @$customFields['analytics_cid'], XenForo_Visitor::getUserId(), @$_SERVER['REMOTE_ADDR'], 'Report', 'Reported', $label);
             }
         }
     }
 }
Example #2
0
 /**
  * Post-save handling.
  *
  * Note: not run when importing
  */
 protected function _postSave()
 {
     parent::_postSave();
     if ($this->isInsert() && !empty(XenForo_Application::getOptions()->dpAnalyticsEvents['registration']) && !empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) {
         if (XenForo_Application::isRegistered('fc')) {
             $action = preg_split('/\\b/', strtolower(trim(XenForo_Application::getFc()->route()->getAction())));
             switch ($action[1]) {
                 case 'facebook':
                     $label = 'Facebook';
                     break;
                 case 'google':
                     $label = 'Google';
                     break;
                 case 'twitter':
                     $label = 'Twitter';
                     break;
                 default:
                     $label = 'Standard';
                     // would have preferred to leave this blank, but a null value causes it to be omitted from certain reports in Analytics
             }
         } else {
             $label = null;
         }
         $user = $this->getMergedData();
         if (XenForo_Application::isRegistered('fc')) {
             $analyticsClientId = XenForo_Application::getFc()->getRequest()->getCookie('_ga');
         } else {
             $analyticsClientId = null;
         }
         DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, $analyticsClientId, $user['user_id'], @$_SERVER['REMOTE_ADDR'], 'User', 'Registration', $label);
     }
 }
Example #3
0
 /**
  * Post-save handling.
  */
 protected function _postSave()
 {
     parent::_postSave();
     if ($this->isInsert() && !empty(XenForo_Application::getOptions()->dpAnalyticsEvents['moderator']) && !empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) {
         $customFields = XenForo_Visitor::getInstance()->get('customFields');
         DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, @$customFields['analytics_cid'], XenForo_Visitor::getUserId(), @$_SERVER['REMOTE_ADDR'], 'Moderator', ucwords(str_replace('_', ' ', $this->get('action'))), (string) new XenForo_Phrase('moderator_log_' . $this->get('content_type') . '_' . $this->get('action'), @json_decode($this->get('action_params'), true)));
     }
 }
Example #4
0
 /**
  * Post-save handling.
  */
 protected function _postSave()
 {
     parent::_postSave();
     if ($this->isInsert() && !empty(XenForo_Application::getOptions()->dpAnalyticsEvents['content']) && !empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) {
         $customFields = XenForo_Visitor::getInstance()->get('customFields');
         $conversation = $this->_getConversationModel()->getConversationMasterById($this->get('conversation_id'));
         DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, @$customFields['analytics_cid'], XenForo_Visitor::getUserId(), @$_SERVER['REMOTE_ADDR'], 'Content', 'Conversation Message', @$conversation['title']);
     }
 }
Example #5
0
 protected function _messagePostSave()
 {
     parent::_messagePostSave();
     if ($this->isInsert() && !empty(XenForo_Application::getOptions()->dpAnalyticsEvents['content']) && !empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) {
         $customFields = XenForo_Visitor::getInstance()->get('customFields');
         $thread = $this->getDiscussionData();
         DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, @$customFields['analytics_cid'], XenForo_Visitor::getUserId(), @$_SERVER['REMOTE_ADDR'], 'Content', 'Post', @$thread['title']);
     }
 }
Example #6
0
 public function logAttachmentView($attachmentId)
 {
     if (!empty(XenForo_Application::getOptions()->dpAnalyticsEvents['attachment']) && !empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) {
         $customFields = XenForo_Visitor::getInstance()->get('customFields');
         $attachment = $this->getAttachmentById($attachmentId);
         DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, @$customFields['analytics_cid'], XenForo_Visitor::getUserId(), @$_SERVER['REMOTE_ADDR'], 'Attachment', 'View', XenForo_Link::buildPublicLink('full:attachments', $attachment));
     }
     parent::logAttachmentView($attachmentId);
 }
Example #7
0
 protected function _messagePostSave()
 {
     parent::_messagePostSave();
     if ($this->isInsert() && !empty(XenForo_Application::getOptions()->dpAnalyticsEvents['content']) && !empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) {
         $customFields = XenForo_Visitor::getInstance()->get('customFields');
         if (!($profileUser = $this->getExtraData(self::DATA_PROFILE_USER))) {
             $userModel = $this->_getUserModel();
             $profileUser = $userModel->getUserById($this->get('profile_user_id'));
         }
         DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, @$customFields['analytics_cid'], XenForo_Visitor::getUserId(), @$_SERVER['REMOTE_ADDR'], 'Content', 'Profile Post', @$profileUser['username']);
     }
 }
Example #8
0
 /**
  * Post-save handling.
  *
  * Note: not run when importing
  */
 protected function _postSave()
 {
     parent::_postSave();
     if ($this->isInsert() && !empty(XenForo_Application::getOptions()->dpAnalyticsEvents['warning']) && !empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) {
         $analyticsClientId = $lastIp = null;
         $userModel = $this->_getUserModel();
         if ($user = $userModel->getUserById($this->get('user_id'), array('join' => XenForo_Model_User::FETCH_USER_PROFILE))) {
             $user = $userModel->prepareUser($user);
             $analyticsClientId = @$user['customFields']['analytics_cid'];
             $lastIp = XenForo_Model::create('DigitalPointBetterAnalytics_Model_Analytics')->getLastIp($user['user_id']);
         }
         DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, $analyticsClientId, $user['user_id'], $lastIp, 'User', 'Warning', @$user['username'] . ': ' . $this->get('title'));
     }
 }
Example #9
0
 public function downgradeUserUpgrade(array $upgrades, $sendAlert = true)
 {
     $this->_filterInput();
     if ($this->_filtered['payment_status'] == 'Refunded' || $this->_filtered['payment_status'] == 'Reversed') {
         foreach ($upgrades as $upgrade) {
             if ($user = $this->getUser(@$upgrade['user_id'])) {
                 $analyticsClientId = @$user['customFields']['analytics_cid'];
                 $lastIp = $this->getModelFromCache('DigitalPointBetterAnalytics_Model_Analytics')->getLastIp(@$upgrade['user_id']);
                 $this->adjustGrossAmount();
                 DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->transaction(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, $analyticsClientId, @$upgrade['user_id'], $lastIp, $this->_filtered['txn_id'], $this->_filtered['mc_gross'], $this->_filtered['mc_currency'], array(array('name' => @$upgrade['title'], 'price' => $this->_filtered['mc_gross'], 'quantity' => 1, 'code' => 'UU-' . @$upgrade['user_upgrade_id'], 'category' => 'User Upgrades', 'action' => 'refund')), @$user['username']);
             }
         }
     }
     parent::downgradeUserUpgrade($upgrades, $sendAlert);
 }
Example #10
0
 public function __destruct()
 {
     if (self::_canUseCurlMulti() && self::$_curlMultiHandle && count(self::$_curlHandles) > 0) {
         do {
             while (($execrun = curl_multi_exec(self::$_curlMultiHandle, $running)) == CURLM_CALL_MULTI_PERFORM) {
             }
             if ($execrun != CURLM_OK) {
                 break;
             }
             while ($done = curl_multi_info_read(self::$_curlMultiHandle)) {
                 curl_multi_remove_handle(self::$_curlMultiHandle, $done['handle']);
             }
         } while ($running);
         curl_multi_close(self::$_curlMultiHandle);
         self::$_curlMultiHandle = null;
     }
 }
Example #11
0
 public static function loadControllerListener($controller, $controllerResponse, $controllerName, $action)
 {
     // checking for FrontController because of some Tapatalk stupidity
     if (!self::$_triggered && XenForo_Application::isRegistered('fc') && $controller->getResponseType() === 'html') {
         self::$_triggered = true;
         if ($clientId = DigitalPointBetterAnalytics_Listener_ControllerPreDispatch::$backendLogging) {
             if (!empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) {
                 /*  Debugging the backend tracker
                 					$e = new ErrorException('CID = ' . $clientId . '/' . DigitalPointBetterAnalytics_Listener_ControllerPreDispatch::$backendLogging . ', UA = ' . @$_SERVER['HTTP_USER_AGENT'] . ', REF = ' . @$_SERVER['HTTP_REFERER'] . ', user_id = ' . XenForo_Visitor::getUserId());
                 					XenForo_Error::logException($e, false);
                 				*/
                 $params = array('dl' => 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . @$_SERVER['HTTP_HOST'] . @$_SERVER['REQUEST_URI'], 'uip' => @$_SERVER['REMOTE_ADDR'], 'ua' => @$_SERVER['HTTP_USER_AGENT'], 'dr' => @$_SERVER['HTTP_REFERER']);
                 DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->pageview(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, $clientId, XenForo_Visitor::getUserId(), $params);
             }
         }
     }
 }
Example #12
0
 public function prepareMailContents($emailTitle = null, array $params = null)
 {
     $response = parent::prepareMailContents($emailTitle, $params);
     if (!empty(XenForo_Application::getOptions()->dpAnalyticsEvents['emails']) && !empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) {
         if (strpos($response['bodyHtml'], '<html>') !== false && !$this->_linksTagged) {
             $this->_linksTagged = true;
             // add medium tracking to body of email
             $response['bodyHtml'] = preg_replace_callback('#(<a href=")(.*?)(")#si', function ($matches) {
                 $parsed = parse_url($matches[2]);
                 @($parsed['query'] = (!empty($parsed['query']) ? $parsed['query'] . '&' : '') . 'utm_source=email&utm_medium=email');
                 return $matches[1] . @$parsed['scheme'] . '://' . @$parsed['host'] . @$parsed['path'] . '?' . $parsed['query'] . (!empty($parsed['fragment']) ? '#' . $parsed['fragment'] : '') . $matches[3];
             }, $response['bodyHtml']);
         }
         if (strpos($response['bodyHtml'], '<html>') === false && !$this->_trackerInserted) {
             $this->_trackerInserted = true;
             // pretty ghetto way of getting user_id, but it (mostly) works and doesn't require completely overwriting Mail methods.
             $email = null;
             if (count($this->_params)) {
                 foreach ($this->_params as $param) {
                     if (is_array($param)) {
                         if (!empty($param['email'])) {
                             $email = $param['email'];
                             break;
                         }
                     }
                 }
             }
             $userId = $lastIp = $analyticsClientId = null;
             if ($email) {
                 $userModel = XenForo_Model::create('XenForo_Model_User');
                 if ($user = $userModel->getUserByEmail($email, array('join' => XenForo_Model_User::FETCH_USER_PROFILE))) {
                     $userId = $user['user_id'];
                     $user = $userModel->prepareUser($user);
                     $analyticsClientId = @$user['customFields']['analytics_cid'];
                     DigitalPointBetterAnalytics_Helper_Analytics::prepareClientId($analyticsClientId);
                     $lastIp = XenForo_Model::create('DigitalPointBetterAnalytics_Model_Analytics')->getLastIp($userId);
                 }
             }
             DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, $analyticsClientId, $userId, $lastIp, 'Email', 'Send', $response['subject'], 'email', true);
             $response['bodyHtml'] .= '<img src="https://www.google-analytics.com/collect?v=1&tid=' . XenForo_Application::getOptions()->googleAnalyticsWebPropertyId . '&cid=' . $analyticsClientId . '&t=event&ec=Email&ea=Open&el=' . urlencode($response['subject']) . ($userId ? '&uid=' . $userId . (XenForo_Application::getOptions()->dpBetterAnalyticsDimensionIndexUser > 0 ? '&cd' . XenForo_Application::getOptions()->dpBetterAnalyticsDimensionIndexUser . '=' . $userId : '') : '') . '&cm=email&z=' . uniqid() . '" />';
         }
     }
     return $response;
 }
Example #13
0
 public function filter_mail($atts)
 {
     $betterAnalyticsOptions = get_option('better_analytics');
     $betterAnalyticsInternal = get_transient('ba_int');
     if ($betterAnalyticsOptions['source_link']['email']) {
         $atts['message'] = preg_replace_callback('#(?<=[^a-z0-9@-]|^)(https?://|www\\.)[^\\s"><]+#iu', array(__CLASS__, '_autoLinkUrlCallbackEmail'), $atts['message']);
     }
     if (!empty($betterAnalyticsOptions['property_id']) && @$betterAnalyticsOptions['events']['email'] && @$betterAnalyticsInternal['v']) {
         $analyticsClientId = uniqid();
         $convertToHtml = false;
         if (is_string($atts['headers'])) {
             if (stripos($atts['headers'], 'text/html') === false) {
                 $convertToHtml = true;
                 $atts['headers'] = preg_replace('#content-type:.*#i', 'Content-Type: text/html; charset=UTF-8', $atts['headers']);
                 if (stripos($atts['headers'], 'text/html') === false) {
                     $atts['headers'] = "Content-Type: text/html; charset=UTF-8\r\n" . $atts['headers'];
                 }
             }
         } elseif (stripos($atts['headers']['content_type'], 'text/html') === false) {
             $convertToHtml = true;
             $atts['headers']['content_type'] = 'Content-Type: text/html; charset=UTF-8';
         }
         if ($convertToHtml) {
             $atts['message'] = '<html><body>' . nl2br(htmlentities($atts['message'])) . '</body></html>';
         }
         $atts['message'] = str_ireplace('</body>', '<img src="https://www.google-analytics.com/collect?v=1&tid=' . urlencode($betterAnalyticsOptions['property_id']) . '&cid=' . $analyticsClientId . '&t=event&ec=Email&ea=Open&el=' . urlencode($atts['subject']) . '&cm=email&z=' . uniqid() . '" />' . '</body>', $atts['message']);
         DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event($betterAnalyticsOptions['property_id'], $analyticsClientId, null, null, 'Email', 'Send', $atts['subject'], 'email', true);
     }
     return $atts;
 }