Subscription Based Reserved Slots and Forum Linked Administrators

TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
edited December 2012 in Modding
<div class="IPBDescription">PHP Based Script for IP Board with Subscription Manager</div>This PHP/MySQL script automatically creates a link between IPBoard or phpBB3 users and one or more Natural Selection 2 servers.

It allows forum administrators to grant admin to various groups of users registered on the forums.
If using IP.Board with Subscriptions Manager or IP.Nexus, you may create subscription based reserved slots / admin privileges. (Currently unsupported with phpBB3 since i'm not aware of any subscription addons - if someone suggests one, i'll make it compatible)

This script allows IP.Board or phpBB3 users to do the following without having to mess with ServerAdmins.json:
(IP.Board is the same board that Unknown Worlds uses, see the page footer).

- Automatically pull admins from certain user groups.
- Automatically grant reserved slots or admin rights to users with subscriptions. (for example, we have a donator subscription. If someone purchases it, they automatically get a reserved slot on our servers, and when subscription expires, the reserved slot is removed - does not work with phpBB3)
- You may setup up to 5 separate groups of admins. (1 subscription based and up to 4 based on forum assigned group, i.e. server admin, moderator, vip, etc.)
- Script ensures that the game server does not crash if an invalid NS2 Steam ID is enterd by a user.
- Script ensures that no errors are thrown that may disrupt the server if php error reporting is enabled.

This script has been tested with IP.Board with the Subscription Manager plugin and phpBB3 by me (TechnIckS) and with IP.Board with IP.Nexus by Maxunit (thanks!!)
To achieve these results it makes use of xDragon's DAK Admin Mod for pulling the config from the web site.

If you do not have IP.Board and are looking to purchase it, please use <a href="https://www.invisionpower.com/clients/index.php?app=nexus&module=promotion&section=referral&id=108604&direct=aHR0cHM6Ly93d3cuaW52aXNpb25wb3dlci5jb20vY2xpZW50cy9pbmRleC5waHA%2F" target="_blank">this link</a> - it will get me a small kickback from the sale :).

Best way to describe the script is to read the Quick Start guide i put together :):

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->/*     ===========================================================================
==============
    
    Subscription Based Reserved Slots and Forum Linked Administrators - V1.1

    Supports the following boards:
     - IP.Board (with subscription manager OR nexus)
     - phpBB3 (tested on 3.0.11)
        
    Developed by: TechnIckS - www.nationalgaming.org
    Contact email: ***censored for forums***
    
    You are free to use this software as you wish, as long as proper credit is given.
    By using this script, either original or modified, I (TechnIckS) am not to be held
    liable for anything that might go wrong. This script is offered without warranty
    of any kind.
    
    Changelog:
    Added checks to prevent empty results throwing php errors.
    Added $subscriptions_enabled to allow subscription mode to be disabled
    Verified functionality with phpBB3. $subscriptions_enabled must be set to false.
    Added information for IP.Nexus. (Thanks Maxunit!)
    Added examples for Server Variables and updated quick start guide to include phpBB3.
    If using Nexus for subscriptions, see the examples below.
    
    ===========================================================================
==============

    Quick start guide:
    
    
    You MUST have DAK Admin Mod installed for this to work and the kQueryURL in DAKConfig.json file set to point to your the output.php file.
    To get DAK Admin Mod, see this link: https://github.com/xToken/DAK
    Instructions for installing DAK Admin Mod are also at the link above.
    Reserved slots plugin MUST be enabled for this to work.
    To create a reserved slot class in DAK Admin Mod, add an admin class with the following characteristics:

        "simple_reserved": { "type": "allowed", "commands": [ "sv_hasreserve", "sv_listadmins" ] }
        
    The sv_hasreserve command does not do anything. However, if a group has access to this command, they are granted a reserved slot. Use this command for any group you would like to grant a reserved slot to.
    
    Start by adding your server's address, username, password and database name.
    
    If you are using IP.Board with Subscriptions Manager, set $subscriptions_enabled to true.
    If you are using phpBB3 or do not wish to use subscriptions, set $subscriptions_enabled to false.
    
    Next, edit the table names and make sure they match yours. For IP Board you will most likely need to only edit the ipboard_ prefix if you used a different prefix.
    For phpBB3, tables are a little different - please read this guide carefully, they are all explained.
    
    Make sure you have an extra field added for users that register. This field should be used for them to enter the NS2ID.
    In IP.Board, to add an extra field, go to control panel -> members -> custom profile fields and add the field there. Make sure NOT to set this as mandatory since not everyone will get a subscription or become an administrator.
    In phpBB3, go to control panel, click "users and groups" and on the left navigation select Custom Profile Fields. There, make a new field. I named mine "nsid", set it to numeric, max length 15, min value 0, max value 999999999999999 (15 9's).
    
    If you use IP.Board, once you create the field, go to the ipboard_pfields_content and find the field you are looking for. Once found, note the pf_id (first column).
    Your $ns2id field will be called "field_xx", where xx is the pf_id. For example, if pf_id is 11, the $ns2id field should be "field_11".
    However, if you do NOT have database access to see the field ID, go to the control panel -> members -> custom profile fields and select the field you have the NS2ID stored in.
    Click on it to edit the field. Now look at the address bar. It should be something like this: "http://www.yourwebsite.com/admin/index.php?adsess=blabla&app=members&&module=cfields&section=customfields&do=edit&id=11"
    Note the numbers at the end (after id=). In this case, it is 11. Your ns2id field should be "field_11".
    
    If you are using phpBB3, simply use "pf_" followed by the name of the field you defined in the control panel (i.e. pf_nsid). Or, if you forgot what it is, go to phpbb_profile_fields_data (NOT phpbb_profile_fields, note the _data at the end) and look at the columns. Find your nsid column there and remember what it's called. Use this for the $ns2id.
    
    For IP.Board, the rest of the variables - name, member_id, subscription_member_id, paid, subscription_status usually do not change, you should not have to modify these.
    For phpBB3, $name should be "username_clean", $member_id should be set to "user_id", $member_group_id should be set to "group_id", $paid should and $subscription_status should be left as is, since these aren't used in phpBB3.
    
    Finally, edit the variables in the last section.
    $full_admin, $standard_admin, $trial_admin, $reserved and $vip are the admin definitions from ServerAdmin.json. These must match the admin types defined there, otherwise your game server WILL break.
    $full_admin_group, $standard_admin_group, $trial_admin_group, $reserved_group and $vip_group variables must be the groups you desire to give reserved slots to (forum user groups).
    Here's how to find these values:
    
    If you are using IP.Board, you can find this information in two ways.
    If you have database access, you can check the g_id values in ipboard_groups table.
    If you do NOT have database access, go to control panel -> members -> member groups -> manage member groups and click on a group that you want to find the ID for.
    Now look at the address bar. The group ID is at the end, same way the field ids are in the previous example.
    I.e. if url is "http://www.yourwebsite.com/admin/index.php?adsess=blabla&app=members&&module=groups&section=groups&do=edit&id=7", the group id is the last number, in this case 7.

    For phpBB3, you can check the table named phpbb_groups and find the group_id there.
    If you do NOT have database access, go to ACP -> users and groups -> manage groups and click "settings" next to the group you want to find the ID for.
    Now look at the address bar. The group ID is at the end, right after g=.
    I.e. if your url is "http://www.yourwebsite.com/adm/index.php?i=groups&sid=blabla&icat=12&mode=manage&action=edit&g=5", the group id is the last number, in this case 5.
    
    If you are not using all groups and would like to eliminate a group if you do not use it, set the numeric value to 0.
    
    To MANUALLY give admin or reserved slots, look at the output.php file, scroll down and uncomment the last lines, and edit them as you wish.
    
    Additional information:
    
    The output.php file is what you should point your server to. Before you do, i recommend accessing the page and making sure everything is outputted correctly.
    
    Here are the definitions of the groups:
    $reserved_group and $reserved are definitions of the group that people with a subscription get moved to. If *MUST* setup subscription manager to move users to this group when they have a valid subscription.
    The rest of the groups are groups that ALWAYS get pulled, regardless of a valid or invalid subsctiption. If you do not use all the groups, feel free to change the group number to 0.
    
    With IP.Board (with subscription manager), when you setup subsctiptions, it is MANDATORY to set your protected groups. For example, any admin or vip classes that should always have admin rights regardless of subscription should be set as protected groups.
    To do this, go to other apps -> subscription manager -> settings, scroll down to protected groups and select all groups that should never be subscription based (i would include the banned group as well to prevent
    people that are banned to change group if a subscription is purchased).
    
    
    Examples for Server Variables:
    
    
    IP.Board with subscriptions manager:
    
    $subscriptions_enabled = true; //set to TRUE if using IPBOARD+SUBSCRIPTION MANAGER. Set to FALSE if using phpbb3 or you do not want to use the subscription module for IP.Board
    $subscriptions = "ipboard_subscription_trans"; //subscription transaction records table name
    $users = "ipboard_members"; //users table name
    $extra_fields = "ipboard_pfields_content"; //extra field table name (custom fields)
    $ns2id = "field_11"; //custom field to be monitored
    $name = "name"; //name of the "name" field in the users table
    $member_id = "member_id"; //member id in the users table
    $member_group_id = "member_group_id"; //member group id in users table
    $subscriptions_member_id = "subtrans_member_id"; //member id field in the subscriptions transaction table
    $paid = "paid"; //active subscription status name (usually "paid")
    $subscription_status = "subtrans_state"; //name of the subscription status field in the subscription transaction table
    

    IP.Board with IP.Nexus (Thanks Maxunit) Note: This example has NO prefixes for the tables. You might have a prefix, please double-check.
    
    $subscriptions_enabled = true; //set to TRUE if using IPBOARD+SUBSCRIPTION MANAGER. Set to FALSE if using phpbb3 or you do not want to use the subscription module for IP.Board
    $subscriptions = "nexus_purchases"; //subscription transaction records table name
    $users = "members"; //users table name
    $extra_fields = "pfields_content"; //extra field table name (custom fields)
    $ns2id = "field_15"; //custom field to be monitored
    $name = "name"; //name of the "name" field in the users table
    $member_id = "member_id"; //member id in the users table
    $member_group_id = "member_group_id"; //member group id in users table
    $subscriptions_member_id = "ps_member"; //member id field in the subscriptions transaction table
    $paid = "1"; //active subscription status name (usually "paid")
    $subscription_status = "ps_active"; //name of the subscription status field in the subscription transaction table


    phpBB3:
    
    $subscriptions_enabled = false; //set to TRUE if using IPBOARD+SUBSCRIPTION MANAGER. Set to FALSE if using phpbb3 or you do not want to use the subscription module for IP.Board
    $subscriptions = "ipboard_subscription_trans"; //subscription transaction records table name
    $users = "phpbb_test_users"; //users table name
    $extra_fields = "phpbb_test_profile_fields_data"; //extra field table name (custom fields)
    $ns2id = "pf_nsid"; //custom field to be monitored
    $name = "username_clean"; //name of the "name" field in the users table
    $member_id = "user_id"; //member id in the users table
    $member_group_id = "group_id"; //member group id in users table
    $subscriptions_member_id = "subtrans_member_id"; //member id field in the subscriptions transaction table
    $paid = "paid"; //active subscription status name (usually "paid")
    $subscription_status = "subtrans_state"; //name of the subscription status field in the subscription transaction table
    
*/<!--c2--></div><!--ec2-->

If using subscriptions, make sure to have it set to automatically change user's group to a special user group made just for users with subscriptions. Use that special group as your subscription group when defining the PHP variables.

Download <a href="http://www.nationalgaming.org/web_server_link_v1.1.zip" target="_blank">here</a>.

Coming soon: Integrating badges using Huze's Player Badges.

If anyone has any questions or suggestions, please let me know, i'll be glad to help!

Comments

  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    edited December 2012
    ** reserved for updates **
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    Planned development:

    - Adding different levels of admins based on subscription type.
  • sleepingsleeping Join Date: 2005-01-16 Member: 35868Members, Constellation, NS2 Map Tester
    edited December 2012
    While I respect your desire to make money for your work, no way I am buying IP board and completely redoing my forums. Would be great if this had multiple support for different forums, at least in the top forum software's. Most people would probably be willing to pay a reasonable fee for it in the correct format.
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    If you tell me what you want to accomplish i would not mind at all to help you out. What forums are you using? Do you have some sort of subscription service or do you want just to manage users from the forum? This way i can edit the code and make it work for your forum. It should not require much more work at all since it's just a matter of changing a few variables!

    (And by the way, i am not trying to make money from it, all i was saying was that if someone was to purchase it, i would not mind them giving a kick back :P. If someone has IPBoard, they can use it anytime.)
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    Forgot to add: If you have PHPBB3 and want to use it, let me know, i do have the latest PHPBB3 still installed. I would only need to know if you have some sort of subscription mod or not and you want to use the paid subscription function. If you don't want to use subscriptions and just hook it with the forum, i can probably make it work fairly quick.
  • sleepingsleeping Join Date: 2005-01-16 Member: 35868Members, Constellation, NS2 Map Tester
    edited December 2012
    Let me say, I was not implying anything malicious, I honestly do think anyone coding should be paid, its a pain in the butt, and I never want to learn it!

    I am currently using PHPBB 3.0.11

    I would like to be able to have people from the server signup on the forums, and then be able to quickly and easily allocate these people to different levels of access wether is be admin privileges / reserved slots / or just a icon next to their name because they are a frequent player, via player badges. Which i am assuming will work with your program because it would just be another admin group in the serveradmin.json file.
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    Player badges should work.

    Do you have access to see your mysql database?
  • MaxunitMaxunit Join Date: 2005-02-01 Member: 39414Members, Reinforced - Shadow
    This is really awesome. I'm a big fan of IP.Board and use it since over 2 years and this would come in very handy.

    I will try it out asap :)

    Thank you a lot for coding this and sharing it.
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    You are welcome! If you have any questions let me know!

    As an additional note, last night I found out that if you use paypal, you have to set it to automatically accept payments from orders without shipping address.
    Otherwise it wont give instant reserved slots until you manually approve transaction.
  • sleepingsleeping Join Date: 2005-01-16 Member: 35868Members, Constellation, NS2 Map Tester
    Hey Wire,

    Sorry for the delay in response, yes I do have access to my MySQL database.
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    Found a little bug. If you have php set to display errors and you do not have any users with subscriptions it will output an error. Same thing happens if you don't have at least one (not one of each) of the non-subscription based admins/vips, etc. This screws up the admin file generated. I'm working on fixing it and i'll post here once it's fixed. Temporary workaround: disable php error reporting OR create at least 1 admin and 1 subscription based user (to make a dummy subscription-based user change a test user's group to the subscription group)


    Sleeping, i am working on it. I am removing the donation part since you don't have a module for that. But you will be able to assign admins/reserved/badges.
  • sleepingsleeping Join Date: 2005-01-16 Member: 35868Members, Constellation, NS2 Map Tester
    Awesome, thanks for your time man.
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    It is taking a little longer than expected, I hit a few roadblocks with PHPBB3 since table structure is somewhat different, but i'm almost done going around them.

    PHPbb3 version should be done soon. But again, no donator functionality, just management of admins and VIPs through forums.
  • MaxunitMaxunit Join Date: 2005-02-01 Member: 39414Members, Reinforced - Shadow
    wireaudio,

    can this plugin even used with IP.Nexus Subscriptions instead of Subscription Manager? I'm currently trying to adjust it in terms of coding and which tables to check, but I might come across some issues, I'm not sure.

    I use IP.Nexus for subscriptions instead of the Subscription Manager.

    If I manage to do that, should I release the modified code here?

    Greetings,

    Maxunit
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    I have not tried with nexus since I don't have it. But yes, if it works send it to me and ill add it to the zip file. Make sure to add any modifications made in the readme file and php file comments.
  • MaxunitMaxunit Join Date: 2005-02-01 Member: 39414Members, Reinforced - Shadow
    Actually, I only had to assign different fields to it and rename "paid" to "1".

    Here's the info I had to enter:

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$subscriptions = "nexus_purchases"; //subscription transaction records table name
    $users = "members"; //users table name
    $extra_fields = "pfields_content"; //extra field table name (custom fields)
    $ns2id = "field_15"; //custom field to be monitored
    $name = "name"; //name of the "name" field in the users table
    $member_id = "member_id"; //member id in the users table
    $member_group_id = "member_group_id"; //member group id in users table
    $subscriptions_member_id = "ps_member"; //member id field in the subscriptions transaction table
    $paid = "1"; //active subscription status name (usually "paid")
    $subscription_status = "ps_active"; //name of the subscription status field in the subscription transaction table<!--c2--></div><!--ec2-->
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    Updated to V1.1

    Changelog:

    Added checks to prevent empty results throwing php errors.
    Added $subscriptions_enabled to allow subscription mode to be disabled
    Verified functionality with phpBB3. $subscriptions_enabled must be set to false.
    Added information for IP.Nexus. (Thanks Maxunit!)
    Added examples for Server Variables and updated quick start guide to include phpBB3.
  • FlyD4wnFlyD4wn Join Date: 2010-04-22 Member: 71484Members
    Thanks alot for this!
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    You are most welcome!

    Can a moderator please change subtitle to "PHP Based Script for IP.Board/phpBB3"
  • IAmSecretSpyIAmSecretSpy Join Date: 2012-12-23 Member: 176006Members, NS2 Playtester, Reinforced - Shadow
    Could you possibly add SMF aswell? They have a built in version of paid subscriptions for usergroups.
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    <a href="http://www.simplemachines.org/" target="_blank">http://www.simplemachines.org/</a>

    is that the one?
  • IAmSecretSpyIAmSecretSpy Join Date: 2012-12-23 Member: 176006Members, NS2 Playtester, Reinforced - Shadow
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    I'll be honest with you I am really busy with the holidays and I probably won't get to it until the 2nd week of January. I am going on vacation this coming Friday until next Friday.
  • IAmSecretSpyIAmSecretSpy Join Date: 2012-12-23 Member: 176006Members, NS2 Playtester, Reinforced - Shadow
    all is well, take your time and enjoy the holidays!
Sign In or Register to comment.