]> git.mxchange.org Git - mailer.git/blobdiff - inc/filter/user_filter.php
Caching of XML/email templates finished:
[mailer.git] / inc / filter / user_filter.php
index 1040aaee4e5f280d7c3103a9b4156553ffc558d9..27980937c239c59933fd785675b2045a815ff148 100644 (file)
@@ -173,5 +173,70 @@ function FILTER_SUBID_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) {
        return $filterData;
 }
 
        return $filterData;
 }
 
+// Generic filter for updating referral counter of currently detected referral id
+function FILTER_GENERIC_UPDATE_USER_REFERRAL ($filterData) {
+       // Make sure the referral id is detected
+       assert(isReferralIdValid());
+
+       // Update ref counter, determineReferralId() must already be called before this filter is executed
+       SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_clicks`=`ref_clicks`+1 WHERE `userid`={%pipe,getReferralId%} LIMIT 1', __FUNCTION__, __LINE__);
+
+       // Return filter data
+       return $filterData;
+}
+
+// Filter for updating sub id records
+function FILTER_UPDATE_USER_SUBID ($filterData) {
+       // Make sure the referral id is detected
+       assert(isReferralIdValid());
+
+       // Get sub id and secure it
+       $subId = SQL_ESCAPE(getRequestElement('subid'));
+
+       // Is the sub id available and registered with referral id?
+       if (countSumTotalData(getReferralId(), 'user_subids', 'id', 'userid', true, sprintf(" AND `subid`='%s'", $subId)) == 1) {
+               // Sub id is assigned to referral id, so add a record
+               SQL_QUERY_ESC("INSERT INTO
+       `{?_MYSQL_PREFIX?}_subid_log`
+(
+       `refid`,
+       `subid`,
+       `referral_url`,
+       `remote_address`,
+       `user_agent`
+) VALUES (
+       {%%pipe,getReferralId%%},
+       '%s',
+       '{%%pipe,detectReferer%%}',
+       '{%%pipe,detectRemoteAddr%%}',
+       '{%%pipe,detectUserAgent%%}'
+)",
+                       array(
+                               // @NOTE: SQL_QUERY_ESC() already escape it, don't use $subId here
+                               getRequestElement('subid')
+                       ), __FUNCTION__, __LINE__);
+
+               // Add insert id for other filters
+               $filterData['insert_id'] = SQL_INSERTID();
+
+               // Register sub id in filter
+               setSession('subid', $subId);
+       } // END - if
+
+       // Return filter data
+       return $filterData;
+}
+
+// Filter for adding member action
+function FILTER_ADD_USER_SUBID_MEMBER_ACTION ($filterData) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
+       // Add entry
+       array_push($filterData, 'list_user_subid');
+
+       // Return data
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
+       return $filterData;
+}
+
 // [EOF]
 ?>
 // [EOF]
 ?>