BinktermPHP includes an integrated credits economy that rewards user participation and allows charging for certain actions. Credits can be used to encourage quality content, manage resource usage, and gamify the BBS experience.
- Configurable credit costs and rewards for various activities
- Daily login bonuses to encourage regular participation
- New user approval bonuses to welcome approved members
- Bonus rewards for longer, higher-quality content
- Transaction history and balance tracking
| Activity | Amount | Type | Notes |
|---|---|---|---|
| Daily Login | +25 | Reward | Awarded once per day after 5-minute delay |
| New User Approval | +100 | Bonus | One-time reward when account is approved |
| Netmail Sent | -5 | Cost | Private messages to other users |
| Echomail Posted | +3 | Reward | Public forum posts |
| Echomail Posted (approx. 2 paragraphs) | +6 | Bonus | 2× reward for substantial posts (2+ paragraphs) |
| Crashmail Sent | -10 | Cost | Direct delivery bypassing uplink |
| Poll Creation | -15 | Cost | Creating a new poll in voting booth |
| File Upload | 0 | Cost | Optional charge applied before a file upload |
| File Upload | 0 | Reward | Optional reward applied after a successful upload |
| File Download | 0 | Cost | Optional charge applied before a file download |
| File Download | 0 | Reward | Optional reward applied after a successful download |
| AI Usage | 0 | Cost | Credits per $0.001 of AI provider spend (configurable rate) |
Credits are configured in config/bbs.json under the credits section. All values are customizable:
{
"credits": {
"enabled": true,
"symbol": "CR",
"daily_amount": 25,
"daily_login_delay_minutes": 5,
"approval_bonus": 100,
"netmail_cost": 1,
"echomail_reward": 5,
"crashmail_cost": 10,
"poll_creation_cost": 15,
"file_upload_cost": 0,
"file_upload_reward": 0,
"file_download_cost": 0,
"file_download_reward": 0,
"ai_credits_per_milli_usd": 0
}
}Settings can also be modified through the web interface at Admin → BBS Settings → Credits System Configuration.
payment— User paid for a servicesystem_reward— Automatic reward for activitydaily_login— Daily login bonusadmin_adjustment— Manual admin modificationnpc_transaction— Transaction with system/gamerefund— Credit refund
Extensions and WebDoors can integrate with the credits system:
// Get user's balance
$balance = UserCredit::getBalance($userId);
// Award credits
UserCredit::credit($userId, 10, 'Completed quest', null, UserCredit::TYPE_SYSTEM_REWARD);
// Charge credits
UserCredit::debit($userId, 5, 'Used service', null, UserCredit::TYPE_PAYMENT);
// Get configurable costs/rewards
$cost = UserCredit::getCreditCost('action_name', $defaultValue);
$reward = UserCredit::getRewardAmount('action_name', $defaultValue);Set "enabled": false in the credits configuration to disable the entire system. When disabled, all credit-related functionality is hidden and no transactions are recorded.
When adding a new UserCredit credit or debit type, update all five of these locations:
src/UserCredit.php— add the new type with a fallback value to the$defaultsarray ingetCreditsConfig(), and add validation in the$mergedarray processing.bbs.json.example— add to thecreditssection with a comment explaining the type.templates/admin/bbs_settings.twig— add a form field in the Credits section, load it inloadBbsSettings(), validate insaveBbsCredits(), and include it in the config object sent to the API.routes/admin-routes.php— in the POST/admin/api/bbs-settingshandler, add validation and include the field in$config['credits']with correct type casting.README.md— document the new type in the credits section.
Configuration priority (highest to lowest): data/bbs.json → bbs.json.example → code defaults in src/UserCredit.php.
Always add code defaults first so the system works even without bbs.json. When updating a template to show credit info, use the credits_enabled Twig variable to conditionally show it.
CRITICAL: Credit balance changes must only happen server-side. JavaScript requests business actions; the server decides whether credits are involved and performs the transaction internally.
❌ POST /api/credits/deduct ← never expose credit endpoints to JS
✅ POST /api/webdoor/game/buy-item ← server handles credits internally, returns new balance
JS may display the balance value returned by the server and communicate it to parent windows via postMessage. It must never calculate or request credit modifications.