0) { echo render_info_or_json($isXHR, 'You have been banned, check your profile for more information.', 403); return; } $subjectId = !empty($_GET['u']) && is_string($_GET['u']) ? (int)$_GET['u'] : 0; $relationType = !empty($_GET['m']) && is_string($_GET['m']) ? (int)$_GET['m'] : -1; if (!user_relation_is_valid_type($relationType)) { echo render_info_or_json($isXHR, 'Invalid relation type.', 400); return; } if ($userId < 1 || $subjectId < 1) { echo render_info_or_json($isXHR, "That user doesn't exist.", 400); return; } if (!user_relation_set($userId, $subjectId, $relationType)) { echo render_info_or_json($isXHR, "Failed to save relation.", 500); return; } if (!$isXHR) { header('Location: ' . $redirect); return; } echo json_encode([ 'user_id' => $userId, 'subject_id' => $subjectId, 'relation_type' => $relationType, ]);