-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-230 Move referral multi account detection handling to an util
- Loading branch information
Showing
3 changed files
with
89 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
.../overview/screens/FirstLogin/utils/effects/handleReferralMultiAccountDetection.effect.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Overview\Screens\FirstLogin\Utils\Effects; | ||
|
||
/** | ||
* @param array $params | ||
* @param arrayRef $params['user'] | ||
* @param number $params['referredById'] | ||
* @param arrayRef $params['referringUserWithTasksData'] | ||
* @param number $params['currentTimestamp'] | ||
*/ | ||
function handleReferralMultiAccountDetection($props) { | ||
global $_EnginePath, $_Included_AlertSystemUtilities; | ||
|
||
$user = &$props['user']; | ||
$userId = $user['id']; | ||
$referredById = $props['referredById']; | ||
$referringUserWithTasksData = &$props['referringUserWithTasksData']; | ||
$currentTimestamp = $props['currentTimestamp']; | ||
|
||
$_Included_AlertSystemUtilities = true; | ||
include($_EnginePath.'includes/functions/AlertSystemUtilities.php'); | ||
|
||
$CheckIntersection = AlertUtils_IPIntersect($userId, $referredById, array | ||
( | ||
'LastTimeDiff' => (TIME_DAY * 60), | ||
'ThisTimeDiff' => (TIME_DAY * 60), | ||
'ThisTimeStamp' => ($currentTimestamp - SERVER_MAINOPEN_TSTAMP) | ||
)); | ||
|
||
if($CheckIntersection !== false) | ||
{ | ||
$FiltersData = array(); | ||
$FiltersData['place'] = 4; | ||
$FiltersData['alertsender'] = 4; | ||
$FiltersData['users'] = array($userId, $referredById); | ||
$FiltersData['ips'] = $CheckIntersection['Intersect']; | ||
$FiltersData['newuser'] = $userId; | ||
$FiltersData['referrer'] = $referredById; | ||
foreach($CheckIntersection['Intersect'] as $IP) | ||
{ | ||
$FiltersData['logcount'][$IP][$userId] = $CheckIntersection['IPLogData'][$userId][$IP]['Count']; | ||
$FiltersData['logcount'][$IP][$referredById] = $CheckIntersection['IPLogData'][$referredById][$IP]['Count']; | ||
} | ||
|
||
$FilterResult = AlertUtils_CheckFilters($FiltersData, array('Save' => true)); | ||
if($FilterResult['SendAlert']) | ||
{ | ||
$_Alert['Data']['ReferrerID'] = $referredById; | ||
foreach($CheckIntersection['Intersect'] as $ThisIPID) | ||
{ | ||
$_Alert['Data']['Intersect'][] = array | ||
( | ||
'IPID' => $ThisIPID, | ||
'NewUser' => $CheckIntersection['IPLogData'][$userId][$ThisIPID], | ||
'OldUser' => $CheckIntersection['IPLogData'][$referredById][$ThisIPID] | ||
); | ||
} | ||
if(!empty($referringUserWithTasksData['TaskData'])) | ||
{ | ||
$_Alert['Data']['Tasks'] = $referringUserWithTasksData['TaskData']; | ||
} | ||
|
||
$Query_AlertOtherUsers .= "SELECT DISTINCT `User_ID` FROM {{table}} WHERE "; | ||
$Query_AlertOtherUsers .= "`User_ID` NOT IN ({$userId}, {$referredById}) AND "; | ||
$Query_AlertOtherUsers .= "`IP_ID` IN (".implode(', ', $CheckIntersection['Intersect']).") AND "; | ||
$Query_AlertOtherUsers .= "`Count` > `FailCount`;"; | ||
$Result_AlertOtherUsers = doquery($Query_AlertOtherUsers, 'user_enterlog'); | ||
if($Result_AlertOtherUsers->num_rows > 0) | ||
{ | ||
while($FetchData = $Result_AlertOtherUsers->fetch_assoc()) | ||
{ | ||
$_Alert['Data']['OtherUsers'][] = $FetchData['User_ID']; | ||
} | ||
} | ||
|
||
Alerts_Add(4, $currentTimestamp, 1, 2, 8, $userId, $_Alert['Data']); | ||
} | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters