Skip to content

Commit 173426e

Browse files
Nyeriahclaude
andauthored
fix(raf): update same-IP text based on endRAFOnSameIP setting (#182)
## Summary - Add `end_raf_on_same_ip` setting to the RAF config defaults and admin panel dropdown - When `endRAFOnSameIP` is **enabled**: keep the existing warning that RAF will be automatically removed - When `endRAFOnSameIP` is **disabled**: show a more coherent message matching [ChromieCraft's wording](https://www.chromiecraft.com/en/recruit-a-friend-is-available-now/) — _"Whilst you can recruit a friend who shares an IP address, you will only get the teleport & XP bonuses, no rewards will be given"_ - Wrap Eluna DB queries in a try/catch so the RAF page shows a clear "No RAF installation found" error instead of a blank page when the database is not configured ## Test plan - [ ] Verify the admin panel shows the new "RAF: End RAF on same IP" dropdown under Eluna settings - [ ] Toggle `end_raf_on_same_ip` to **Enabled** and confirm the original warning text appears on the RAF page - [ ] Toggle `end_raf_on_same_ip` to **Disabled** and confirm the updated ChromieCraft-style text appears - [ ] Disconnect or misconfigure the Eluna database and verify the RAF page shows the friendly error message instead of a blank page 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3203e18 commit 173426e

File tree

4 files changed

+49
-26
lines changed

4 files changed

+49
-26
lines changed

src/acore-wp-plugin/src/Components/AdminPanel/Pages/ElunaSettings.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@
9696
</select>
9797
</td>
9898
</tr>
99+
<tr class="eluna_raf_config" <?php if (Opts::I()->eluna_recruit_a_friend != '1') echo 'style="display:none;"'?>>
100+
<th>
101+
<label for="eluna_raf_config[end_raf_on_same_ip]">RAF: End RAF on same IP</label>
102+
</th>
103+
<td>
104+
<select name="eluna_raf_config[end_raf_on_same_ip]" id="eluna_raf_config_end_raf_on_same_ip">
105+
<option value="0">Disabled</option>
106+
<option value="1" <?php if (Opts::I()->eluna_raf_config['end_raf_on_same_ip'] === '1') echo 'selected'; ?>>Enabled</option>
107+
</select>
108+
</td>
109+
</tr>
99110
</tbody>
100111
</table>
101112
</div>

src/acore-wp-plugin/src/Components/UserPanel/Pages/RafProgressPage.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
echo "<h2>" . __('Recruit a Friend', Opts::I()->page_alias) . "</h2>";
1313
?>
1414
<p>Recruit your friends, help them to level up and get very awesome unique prizes.</p>
15+
<?php if (Opts::I()->eluna_raf_config['end_raf_on_same_ip'] === '1') { ?>
1516
<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>
17+
<?php } else { ?>
18+
<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>
19+
<?php } ?>
1620
<div class="row">
1721
<div class="col-sm-6">
1822
<div class="card">

src/acore-wp-plugin/src/Components/UserPanel/UserController.php

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -97,32 +97,40 @@ public function showRafProgress() {
9797
if (!isset($accId)) {
9898
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>");
9999
}
100-
$query = "SELECT `account_id`, `recruiter_account`, `time_stamp`, `ip_abuse_counter`, `kick_counter`
101-
FROM `recruit_a_friend_links`
102-
WHERE `account_id` = $accId
103-
";
104-
$conn = $acServices->getElunaMgr()->getConnection();
105-
$queryResult = $conn->executeQuery($query);
106-
$rafPersonalInfo = $queryResult->fetchAssociative();
107-
108-
$query = "SELECT COALESCE(`reward_level`, 0) as reward_level
109-
FROM `recruit_a_friend_rewards`
110-
WHERE `recruiter_account` = $accId
111-
";
112-
$conn = $acServices->getElunaMgr()->getConnection();
113-
$queryResult = $conn->executeQuery($query);
114-
$rafPersonalProgress = $queryResult->fetchAssociative();
115-
116-
if (!isset($rafPersonalProgress['reward_level'])) {
117-
$rafPersonalProgress = ['reward_level' => 0];
118-
}
119100

120-
$query = "SELECT `account_id`, `recruiter_account`, `time_stamp`, `ip_abuse_counter`, `kick_counter`
121-
FROM `recruit_a_friend_links`
122-
WHERE `recruiter_account` = $accId
123-
";
124-
$queryResult = $conn->executeQuery($query);
125-
$rafRecruitedInfo = $queryResult->fetchAllAssociative();
101+
try {
102+
$conn = $acServices->getElunaMgr()->getConnection();
103+
104+
$query = "SELECT `account_id`, `recruiter_account`, `time_stamp`, `ip_abuse_counter`, `kick_counter`
105+
FROM `recruit_a_friend_links`
106+
WHERE `account_id` = $accId
107+
";
108+
$queryResult = $conn->executeQuery($query);
109+
$rafPersonalInfo = $queryResult->fetchAssociative();
110+
111+
$query = "SELECT COALESCE(`reward_level`, 0) as reward_level
112+
FROM `recruit_a_friend_rewards`
113+
WHERE `recruiter_account` = $accId
114+
";
115+
$queryResult = $conn->executeQuery($query);
116+
$rafPersonalProgress = $queryResult->fetchAssociative();
117+
118+
if (!isset($rafPersonalProgress['reward_level'])) {
119+
$rafPersonalProgress = ['reward_level' => 0];
120+
}
121+
122+
$query = "SELECT `account_id`, `recruiter_account`, `time_stamp`, `ip_abuse_counter`, `kick_counter`
123+
FROM `recruit_a_friend_links`
124+
WHERE `recruiter_account` = $accId
125+
";
126+
$queryResult = $conn->executeQuery($query);
127+
$rafRecruitedInfo = $queryResult->fetchAllAssociative();
128+
} catch (\Exception $e) {
129+
echo '<div class="wrap"><h2>Recruit a Friend</h2>'
130+
. '<div class="notice notice-error"><p>No Recruit-A-Friend installation was found. '
131+
. 'Please ensure the Eluna database is properly configured and the RAF module is installed on your server.</p></div></div>';
132+
return;
133+
}
126134

127135
echo $this->getView()->getRafProgressRender($rafPersonalInfo, $rafPersonalProgress, $rafRecruitedInfo);
128136
}

src/acore-wp-plugin/src/Manager/Opts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Opts {
3636
public $acore_db_eluna_pass="";
3737
public $acore_db_eluna_name="";
3838
public $eluna_recruit_a_friend="";
39-
public $eluna_raf_config=["check_ip" => '0'];
39+
public $eluna_raf_config=["check_ip" => '0', "end_raf_on_same_ip" => '1'];
4040
public $acore_resurrection_scroll="";
4141
public $acore_resurrection_scroll_days_inactive="180";
4242
public $acore_item_restoration="";

0 commit comments

Comments
 (0)