Code Duplication    Length = 3-6 lines in 3 locations

main/auth/profile.php 1 location

@@ 27-29 (lines=3) @@
24
25
$_SESSION['this_section'] = $this_section;
26
27
if (!(isset($_user['user_id']) && $_user['user_id']) || api_is_anonymous($_user['user_id'], true)) {
28
    api_not_allowed(true);
29
}
30
31
$gMapsPlugin = GoogleMapsPlugin::create();
32
$geolocalization = $gMapsPlugin->get('enable_api') === 'true';

main/survey/fillsurvey.php 1 location

@@ 68-73 (lines=6) @@
65
    $resultAnonymous = Database::query($sql);
66
    $rowAnonymous = Database::fetch_array($resultAnonymous, 'ASSOC');
67
    // If is anonymous and is not allowed to take the survey to anonymous users, forbid access:
68
    if (!isset($rowAnonymous['anonymous']) ||
69
        ($rowAnonymous['anonymous'] == 0 && api_is_anonymous()) ||
70
        count($rowAnonymous) == 0
71
    ) {
72
        api_not_allowed(true);
73
    }
74
    // If is anonymous and it is allowed to take the survey as anonymous, mark survey as anonymous.
75
}
76

main/inc/lib/api.lib.php 1 location

@@ 1175-1178 (lines=4) @@
1172
function api_block_anonymous_users($printHeaders = true)
1173
{
1174
    $user = api_get_user_info();
1175
    if (!(isset($user['user_id']) && $user['user_id']) || api_is_anonymous($user['user_id'], true)) {
1176
        api_not_allowed($printHeaders);
1177
        return false;
1178
    }
1179
1180
    return true;
1181
}