@@ -21,62 +21,88 @@ function handleReferralMultiAccountDetection($props) {
21
21
$ _Included_AlertSystemUtilities = true ;
22
22
include ($ _EnginePath .'includes/functions/AlertSystemUtilities.php ' );
23
23
24
- $ CheckIntersection = AlertUtils_IPIntersect ($ userId , $ referredById , array
25
- (
26
- 'LastTimeDiff ' => (TIME_DAY * 60 ),
27
- 'ThisTimeDiff ' => (TIME_DAY * 60 ),
28
- 'ThisTimeStamp ' => ($ currentTimestamp - SERVER_MAINOPEN_TSTAMP )
29
- ));
30
-
31
- if ($ CheckIntersection !== false )
32
- {
33
- $ FiltersData = array ();
34
- $ FiltersData ['place ' ] = 4 ;
35
- $ FiltersData ['alertsender ' ] = 4 ;
36
- $ FiltersData ['users ' ] = array ($ userId , $ referredById );
37
- $ FiltersData ['ips ' ] = $ CheckIntersection ['Intersect ' ];
38
- $ FiltersData ['newuser ' ] = $ userId ;
39
- $ FiltersData ['referrer ' ] = $ referredById ;
40
- foreach ($ CheckIntersection ['Intersect ' ] as $ IP )
41
- {
42
- $ FiltersData ['logcount ' ][$ IP ][$ userId ] = $ CheckIntersection ['IPLogData ' ][$ userId ][$ IP ]['Count ' ];
43
- $ FiltersData ['logcount ' ][$ IP ][$ referredById ] = $ CheckIntersection ['IPLogData ' ][$ referredById ][$ IP ]['Count ' ];
24
+ $ intersectionCheckResult = AlertUtils_IPIntersect (
25
+ $ userId ,
26
+ $ referredById ,
27
+ [
28
+ 'LastTimeDiff ' => (TIME_DAY * 60 ),
29
+ 'ThisTimeDiff ' => (TIME_DAY * 60 ),
30
+ 'ThisTimeStamp ' => ($ currentTimestamp - SERVER_MAINOPEN_TSTAMP )
31
+ ]
32
+ );
33
+
34
+ if ($ intersectionCheckResult === false ) {
35
+ return ;
36
+ }
37
+
38
+ $ ALERT_SENDER = 4 ;
39
+
40
+ $ alertSystemFilterParams = [];
41
+ $ alertSystemFilterParams ['place ' ] = 4 ;
42
+ $ alertSystemFilterParams ['alertsender ' ] = $ ALERT_SENDER ;
43
+ $ alertSystemFilterParams ['users ' ] = [
44
+ $ userId ,
45
+ $ referredById ,
46
+ ];
47
+ $ alertSystemFilterParams ['ips ' ] = $ intersectionCheckResult ['Intersect ' ];
48
+ $ alertSystemFilterParams ['newuser ' ] = $ userId ;
49
+ $ alertSystemFilterParams ['referrer ' ] = $ referredById ;
50
+ $ alertSystemFilterParams ['logcount ' ] = object_map (
51
+ $ intersectionCheckResult ['Intersect ' ],
52
+ function ($ intersectedIpId ) use ($ intersectionCheckResult , $ userId , $ referredById ) {
53
+ return [
54
+ [
55
+ $ userId => $ intersectionCheckResult ['IPLogData ' ][$ userId ][$ intersectedIpId ]['Count ' ],
56
+ $ referredById => $ intersectionCheckResult ['IPLogData ' ][$ referredById ][$ intersectedIpId ]['Count ' ],
57
+ ],
58
+ $ intersectedIpId
59
+ ];
44
60
}
61
+ );
62
+
63
+ $ alertSystemFilterResult = AlertUtils_CheckFilters (
64
+ $ alertSystemFilterParams ,
65
+ [
66
+ 'Save ' => true ,
67
+ ]
68
+ );
45
69
46
- $ FilterResult = AlertUtils_CheckFilters ($ FiltersData , array ('Save ' => true ));
47
- if ($ FilterResult ['SendAlert ' ])
48
- {
49
- $ _Alert ['Data ' ]['ReferrerID ' ] = $ referredById ;
50
- foreach ($ CheckIntersection ['Intersect ' ] as $ ThisIPID )
51
- {
52
- $ _Alert ['Data ' ]['Intersect ' ][] = array
53
- (
54
- 'IPID ' => $ ThisIPID ,
55
- 'NewUser ' => $ CheckIntersection ['IPLogData ' ][$ userId ][$ ThisIPID ],
56
- 'OldUser ' => $ CheckIntersection ['IPLogData ' ][$ referredById ][$ ThisIPID ]
57
- );
58
- }
59
- if (!empty ($ referringUserWithTasksData ['TaskData ' ]))
60
- {
61
- $ _Alert ['Data ' ]['Tasks ' ] = $ referringUserWithTasksData ['TaskData ' ];
62
- }
63
-
64
- $ Query_AlertOtherUsers .= "SELECT DISTINCT `User_ID` FROM {{table}} WHERE " ;
65
- $ Query_AlertOtherUsers .= "`User_ID` NOT IN ( {$ userId }, {$ referredById }) AND " ;
66
- $ Query_AlertOtherUsers .= "`IP_ID` IN ( " .implode (', ' , $ CheckIntersection ['Intersect ' ]).") AND " ;
67
- $ Query_AlertOtherUsers .= "`Count` > `FailCount`; " ;
68
- $ Result_AlertOtherUsers = doquery ($ Query_AlertOtherUsers , 'user_enterlog ' );
69
- if ($ Result_AlertOtherUsers ->num_rows > 0 )
70
- {
71
- while ($ FetchData = $ Result_AlertOtherUsers ->fetch_assoc ())
72
- {
73
- $ _Alert ['Data ' ]['OtherUsers ' ][] = $ FetchData ['User_ID ' ];
70
+ if (!$ alertSystemFilterResult ['SendAlert ' ]) {
71
+ return ;
72
+ }
73
+
74
+ $ alertParams = [
75
+ 'Data ' => [
76
+ 'ReferrerID ' => $ referredById ,
77
+ 'Intersect ' => array_map_withkeys (
78
+ $ intersectionCheckResult ['Intersect ' ],
79
+ function ($ intersectedIpId ) use ($ intersectionCheckResult , $ userId , $ referredById ) {
80
+ return [
81
+ 'IPID ' => $ intersectedIpId ,
82
+ 'NewUser ' => $ intersectionCheckResult ['IPLogData ' ][$ userId ][$ intersectedIpId ],
83
+ 'OldUser ' => $ intersectionCheckResult ['IPLogData ' ][$ referredById ][$ intersectedIpId ],
84
+ ];
74
85
}
75
- }
86
+ ),
87
+ ],
88
+ ];
76
89
77
- Alerts_Add ( 4 , $ currentTimestamp , 1 , 2 , 8 , $ userId , $ _Alert [ ' Data ' ]);
78
- }
90
+ if (! empty ( $ referringUserWithTasksData [ ' TaskData ' ])) {
91
+ $ alertParams [ ' Data ' ][ ' Tasks ' ] = $ referringUserWithTasksData [ ' TaskData ' ];
79
92
}
93
+
94
+ $ Query_AlertOtherUsers = '' ;
95
+ $ Query_AlertOtherUsers .= "SELECT DISTINCT `User_ID` FROM {{table}} WHERE " ;
96
+ $ Query_AlertOtherUsers .= "`User_ID` NOT IN ( {$ userId }, {$ referredById }) AND " ;
97
+ $ Query_AlertOtherUsers .= "`IP_ID` IN ( " .implode (', ' , $ intersectionCheckResult ['Intersect ' ]).") AND " ;
98
+ $ Query_AlertOtherUsers .= "`Count` > `FailCount`; " ;
99
+ $ Result_AlertOtherUsers = doquery ($ Query_AlertOtherUsers , 'user_enterlog ' );
100
+
101
+ $ alertParams ['Data ' ]['OtherUsers ' ] = mapQueryResults ($ Result_AlertOtherUsers , function ($ otherUserEntry ) {
102
+ return $ otherUserEntry ['User_ID ' ];
103
+ });
104
+
105
+ Alerts_Add ($ ALERT_SENDER , $ currentTimestamp , 1 , 2 , 8 , $ userId , $ alertParams ['Data ' ]);
80
106
}
81
107
82
108
?>
0 commit comments