Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@
</select>
</td>
</tr>
<tr class="eluna_raf_config" <?php if (Opts::I()->eluna_recruit_a_friend != '1') echo 'style="display:none;"'?>>
<th>
<label for="eluna_raf_config[end_raf_on_same_ip]">RAF: End RAF on same IP</label>
</th>
<td>
<select name="eluna_raf_config[end_raf_on_same_ip]" id="eluna_raf_config_end_raf_on_same_ip">
<option value="0">Disabled</option>
<option value="1" <?php if (Opts::I()->eluna_raf_config['end_raf_on_same_ip'] === '1') echo 'selected'; ?>>Enabled</option>
</select>
</td>
</tr>
</tbody>
</table>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
echo "<h2>" . __('Recruit a Friend', Opts::I()->page_alias) . "</h2>";
?>
<p>Recruit your friends, help them to level up and get very awesome unique prizes.</p>
<?php if (Opts::I()->eluna_raf_config['end_raf_on_same_ip'] === '1') { ?>
<p style="color: red; font-size: 20px;">Recruiting from the same IP address will cause the RAF to be automatically removed and no new RAF can be applied again.</p>
<?php } else { ?>
<p style="color: red; font-size: 20px;">Whilst you can recruit a friend who shares an IP address, you will only get the teleport &amp; XP bonuses, no rewards will be given (these are provided only to those who recruit people not on their own IP address).</p>
<?php } ?>
<div class="row">
<div class="col-sm-6">
<div class="card">
Expand Down
58 changes: 33 additions & 25 deletions src/acore-wp-plugin/src/Components/UserPanel/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,32 +97,40 @@ public function showRafProgress() {
if (!isset($accId)) {
wp_die("<div class=\"notice notice-error\"><p>An error ocurred while loading your account information, please try again later. If this errors continues, please ask for support.</p></div>");
}
$query = "SELECT `account_id`, `recruiter_account`, `time_stamp`, `ip_abuse_counter`, `kick_counter`
FROM `recruit_a_friend_links`
WHERE `account_id` = $accId
";
$conn = $acServices->getElunaMgr()->getConnection();
$queryResult = $conn->executeQuery($query);
$rafPersonalInfo = $queryResult->fetchAssociative();

$query = "SELECT COALESCE(`reward_level`, 0) as reward_level
FROM `recruit_a_friend_rewards`
WHERE `recruiter_account` = $accId
";
$conn = $acServices->getElunaMgr()->getConnection();
$queryResult = $conn->executeQuery($query);
$rafPersonalProgress = $queryResult->fetchAssociative();

if (!isset($rafPersonalProgress['reward_level'])) {
$rafPersonalProgress = ['reward_level' => 0];
}

$query = "SELECT `account_id`, `recruiter_account`, `time_stamp`, `ip_abuse_counter`, `kick_counter`
FROM `recruit_a_friend_links`
WHERE `recruiter_account` = $accId
";
$queryResult = $conn->executeQuery($query);
$rafRecruitedInfo = $queryResult->fetchAllAssociative();
try {
$conn = $acServices->getElunaMgr()->getConnection();

$query = "SELECT `account_id`, `recruiter_account`, `time_stamp`, `ip_abuse_counter`, `kick_counter`
FROM `recruit_a_friend_links`
WHERE `account_id` = $accId
";
$queryResult = $conn->executeQuery($query);
$rafPersonalInfo = $queryResult->fetchAssociative();

$query = "SELECT COALESCE(`reward_level`, 0) as reward_level
FROM `recruit_a_friend_rewards`
WHERE `recruiter_account` = $accId
";
$queryResult = $conn->executeQuery($query);
$rafPersonalProgress = $queryResult->fetchAssociative();

if (!isset($rafPersonalProgress['reward_level'])) {
$rafPersonalProgress = ['reward_level' => 0];
}

$query = "SELECT `account_id`, `recruiter_account`, `time_stamp`, `ip_abuse_counter`, `kick_counter`
FROM `recruit_a_friend_links`
WHERE `recruiter_account` = $accId
";
$queryResult = $conn->executeQuery($query);
$rafRecruitedInfo = $queryResult->fetchAllAssociative();
} catch (\Exception $e) {
echo '<div class="wrap"><h2>Recruit a Friend</h2>'
. '<div class="notice notice-error"><p>No Recruit-A-Friend installation was found. '
. 'Please ensure the Eluna database is properly configured and the RAF module is installed on your server.</p></div></div>';
return;
}

echo $this->getView()->getRafProgressRender($rafPersonalInfo, $rafPersonalProgress, $rafRecruitedInfo);
}
Expand Down
2 changes: 1 addition & 1 deletion src/acore-wp-plugin/src/Manager/Opts.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Opts {
public $acore_db_eluna_pass="";
public $acore_db_eluna_name="";
public $eluna_recruit_a_friend="";
public $eluna_raf_config=["check_ip" => '0'];
public $eluna_raf_config=["check_ip" => '0', "end_raf_on_same_ip" => '1'];
public $acore_resurrection_scroll="";
public $acore_resurrection_scroll_days_inactive="180";
public $acore_item_restoration="";
Expand Down
Loading