diff --git a/.idea/allianceauth.iml b/.idea/allianceauth.iml index e3ceed9c..199266bc 100755 --- a/.idea/allianceauth.iml +++ b/.idea/allianceauth.iml @@ -1,26 +1,26 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/.idea/dataSources.ids b/.idea/dataSources.ids index b1659e35..fc5e4cc3 100755 --- a/.idea/dataSources.ids +++ b/.idea/dataSources.ids @@ -1,4 +1,4 @@ - + diff --git a/.idea/encodings.xml b/.idea/encodings.xml index e206d70d..7c62b52a 100755 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,5 +1,5 @@ - - - - - + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index 6fdcbcf7..9e616ddf 100755 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,5 @@ - - - - - + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml index 97f7bc20..9db87eb2 100755 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -1,9 +1,9 @@ - - - - - - - - - + + + + + + + + + diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml index 922003b8..0d5175ca 100755 --- a/.idea/scopes/scope_settings.xml +++ b/.idea/scopes/scope_settings.xml @@ -1,5 +1,5 @@ - - - + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index c80f2198..ab55cf16 100755 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/alliance_auth/settings.py.example b/alliance_auth/settings.py.example index 299bbcda..c19e87ce 100755 --- a/alliance_auth/settings.py.example +++ b/alliance_auth/settings.py.example @@ -180,10 +180,12 @@ DEFAULT_BLUE_GROUP = 'BlueMember' # ENABLE_ALLIANCE_FORUM - Enable forum support in the auth for alliance members # ENABLE_ALLIANCE_JABBER - Enable jabber support in the auth for alliance members # ENABLE_ALLIANCE_MUMBLE - Enable mumble support in the auth for alliance members +# ENABLE_ALLIANCE_IPBOARD - Enable IPBoard forum support in the auth for alliance members ######################### ENABLE_ALLIANCE_FORUM = True ENABLE_ALLIANCE_JABBER = True ENABLE_ALLIANCE_MUMBLE = True +ENABLE_ALLIANCE_IPBOARD = False ##################### # Blue service Setup @@ -191,10 +193,12 @@ ENABLE_ALLIANCE_MUMBLE = True # ENABLE_BLUE_FORUM - Enable forum support in the auth for blues # ENABLE_BLUE_JABBER - Enable jabber support in the auth for blues # ENABLE_BLUE_MUMBLE - Enable mumble support in the auth for blues +# ENABLE_BLUE_IPBOARD - Enable IPBoard forum support in the auth for blues ##################### ENABLE_BLUE_FORUM = False ENABLE_BLUE_JABBER = False ENABLE_BLUE_MUMBLE = True +ENABLE_BLUE_IPBOARD = False ######################### # Alliance Configuration @@ -215,8 +219,14 @@ ALLIANCE_BLUE_STANDING = 5.0 # Forum Configuration ##################### # FORUM_URL - Forum url location +# IPBOARD_ENDPOINT - Api endpoint if using ipboard +# IPBOARD_APIKEY - Api key to interact with ipboard +# IPBOARD_APIMODULE - Module for alliance auth *leave alone* ##################### FORUM_URL = "http://someaddress.com" +IPBOARD_ENDPOINT = 'someaddress.com/interface/board/index.php' +IPBOARD_APIKEY = 'somekeyhere' +IPBOARD_APIMODULE = 'aa' ###################### # Jabber Configuration diff --git a/alliance_auth/urls.py b/alliance_auth/urls.py index 372f0188..57c17c04 100755 --- a/alliance_auth/urls.py +++ b/alliance_auth/urls.py @@ -86,12 +86,6 @@ urlpatterns = patterns('', url(r'^reset_forum_password/$', 'services.views.reset_forum_password', name='auth_reset_forum_password'), - url(r'^activate_blue_forum/$', 'services.views.activate_blue_forum', - name='auth_activate_blue_forum'), - url(r'^deactivate_blue_forum/$', 'services.views.deactivate_blue_forum', - name='auth_deactivate_blue_forum'), - url(r'^reset_blue_forum_password/$', 'services.views.reset_blue_forum_password', - name='auth_reset_blue_forum_password'), # Jabber Service Control url(r'^activate_jabber/$', 'services.views.activate_jabber', name='auth_activate_jabber'), @@ -99,25 +93,16 @@ urlpatterns = patterns('', url(r'^reset_jabber_password/$', 'services.views.reset_jabber_password', name='auth_reset_jabber_password'), - url(r'^activate_blue_jabber/$', 'services.views.activate_blue_jabber', - name='auth_activate_blue_jabber'), - url(r'^deactivate_blue_jabber/$', 'services.views.deactivate_blue_jabber', - name='auth_deactivate_blue_jabber'), - url(r'^reset_blue_jabber_password/$', 'services.views.reset_blue_jabber_password', - name='auth_reset_blue_jabber_password'), - # Mumble service control url(r'^activate_mumble/$', 'services.views.activate_mumble', name='auth_activate_mumble'), url(r'^deactivate_mumble/$', 'services.views.deactivate_mumble', name='auth_deactivate_mumble'), url(r'^reset_mumble_password/$', 'services.views.reset_mumble_password', name='auth_reset_mumble_password'), - url(r'^activate_blue_mumble/$', 'services.views.activate_blue_mumble', - name='auth_activate_blue_mumble'), - url(r'^deactivate_blue_mumble/$', 'services.views.deactivate_blue_mumble', - name='auth_deactivate_blue_mumble'), - url(r'^reset_blue_mumble_password/$', 'services.views.reset_blue_mumble_password', - name='auth_reset_blue_mumble_password'), + # Ipboard service control + url(r'^activate_ipboard/$', 'services.views.activate_ipboard_forum', name='auth_activate_ipboard'), + url(r'^deactivate_ipboard/$', 'services.views.deactivate_ipboard_forum', name='auth_deactivate_ipboard'), + url(r'^reset_ipboard_password/$', 'services.views.reset_ipboard_password', name='auth_reset_ipboard_password'), # Tools url(r'^tool/fleet_formatter_tool/$', 'services.views.fleet_formatter_view', diff --git a/authentication/managers.py b/authentication/managers.py old mode 100644 new mode 100755 index 0e63b6f6..e4359e81 --- a/authentication/managers.py +++ b/authentication/managers.py @@ -57,6 +57,14 @@ class AuthServicesInfoManager: authserviceinfo.mumble_password = password authserviceinfo.save(update_fields=['mumble_username', 'mumble_password']) + @staticmethod + def update_user_ipboard_info(username, password, user): + if User.objects.filter(username=user.username).exists(): + authserviceinfo = AuthServicesInfoManager.__get_or_create(user) + authserviceinfo.ipboard_username = username + authserviceinfo.ipboard_password = password + authserviceinfo.save(update_fields=['ipboard_username', 'ipboard_password']) + @staticmethod def update_is_blue(is_blue, user): if User.objects.filter(username=user.username).exists(): diff --git a/authentication/models.py b/authentication/models.py old mode 100644 new mode 100755 index 12d25074..ab64ea76 --- a/authentication/models.py +++ b/authentication/models.py @@ -3,6 +3,8 @@ from django.contrib.auth.models import User class AuthServicesInfo(models.Model): + ipboard_username = models.CharField(max_length=254, default="") + ipboard_password = models.CharField(max_length=254, default="") forum_username = models.CharField(max_length=254, default="") forum_password = models.CharField(max_length=254, default="") jabber_username = models.CharField(max_length=254, default="") diff --git a/celerytask/tasks.py b/celerytask/tasks.py old mode 100644 new mode 100755 index 2e30438f..a4ad0612 --- a/celerytask/tasks.py +++ b/celerytask/tasks.py @@ -4,9 +4,10 @@ from django.contrib.auth.models import User from models import SyncGroupCache from celery.task.schedules import crontab -from services.managers.jabber_manager import JabberManager +from services.managers.openfire_manager import OpenfireManager from services.managers.mumble_manager import MumbleManager -from services.managers.forum_manager import ForumManager +from services.managers.phpbb3_manager import Phpbb3Manager +from services.managers.ipboard_manager import IPBoardManager from authentication.models import AuthServicesInfo from eveonline.managers import EveManager from services.managers.eve_api_manager import EveApiManager @@ -23,7 +24,7 @@ def update_jabber_groups(user): if len(groups) == 0: groups.append('empty') - JabberManager.update_user_groups(authserviceinfo.jabber_username, authserviceinfo.jabber_password, groups) + OpenfireManager.update_user_groups(authserviceinfo.jabber_username, authserviceinfo.jabber_password, groups) def update_mumble_groups(user): @@ -49,7 +50,20 @@ def update_forum_groups(user): if len(groups) == 0: groups.append('empty') - ForumManager.update_groups(authserviceinfo.forum_username, groups) + Phpbb3Manager.update_groups(authserviceinfo.forum_username, groups) + + +def update_ipboard_groups(user): + syncgroups = SyncGroupCache.objects.filter(user=user) + authserviceinfo = AuthServicesInfo.objects.get(user=user) + groups = [] + for syncgroup in syncgroups: + groups.append(str(syncgroup.groupname)) + + if len(groups) == 0: + groups.append('empty') + + IPBoardManager.update_groups(authserviceinfo.ipboard_username, groups) def add_to_databases(user, groups, syncgroups): @@ -79,6 +93,8 @@ def add_to_databases(user, groups, syncgroups): update_mumble_groups(user) if authserviceinfo.forum_username != "": update_forum_groups(user) + if authserviceinfo.ipboard_username != "": + update_ipboard_groups(user) def remove_from_databases(user, groups, syncgroups): @@ -104,6 +120,8 @@ def remove_from_databases(user, groups, syncgroups): update_mumble_groups(user) if authserviceinfo.forum_username != "": update_forum_groups(user) + if authserviceinfo.ipboard_username != "": + update_ipboard_groups(user) # Run every minute diff --git a/services/managers/ipboard_manager.py b/services/managers/ipboard_manager.py new file mode 100755 index 00000000..7cd67407 --- /dev/null +++ b/services/managers/ipboard_manager.py @@ -0,0 +1,125 @@ +import os +import xmlrpclib +from hashlib import md5 + +from django.conf import settings + +class IPBoardManager: + + def __init__(self): + pass + + @staticmethod + def __santatize_username(username): + sanatized = username.replace(" ", "_") + sanatized = sanatized.replace("'", "") + return sanatized.lower() + + @staticmethod + def __generate_random_pass(): + return os.urandom(8).encode('hex') + + @staticmethod + def exec_xmlrpc(func, **kwargs): + """ Send a XMLRPC request """ + + server = xmlrpclib.Server(settings.IPBOARD_ENDPOINT, verbose=False) + params = {} + for i in kwargs: + params[i] = kwargs[i] + params['api_key'] = settings.IPBOARD_APIKEY + params['api_module'] = settings.IPBOARD_APIMODULE + print params + return getattr(server, func)(params) + + @staticmethod + def add_user(username, email): + """ Add user to service """ + sanatized = str(IPBoardManager.__santatize_username(username)) + plain_password = IPBoardManager.__generate_random_pass() + password = md5(plain_password).hexdigest() + ret = IPBoardManager.exec_xmlrpc('createUser', username=sanatized, email=str(email), display_name=sanatized, md5_passwordHash=password) + return sanatized, plain_password + + @staticmethod + def delete_user(username): + """ Delete user """ + ret = IPBoardManager.exec_xmlrpc('deleteUser', username=username) + return username + + @staticmethod + def disable_user(username): + """ Disable user """ + ret = IPBoardManager.exec_xmlrpc('disableUser', username=username) + return username + + @staticmethod + def update_user(username, email, password): + """ Add user to service """ + password = md5(password).hexdigest() + ret = IPBoardManager.exec_xmlrpc('updateUser', username=username, email=email, md5_passwordHash=password) + return username + + @staticmethod + def get_all_groups(): + groups = [] + ret = IPBoardManager.exec_xmlrpc('getAllGroups') + for group in ret: + groups.append(group["g_title"]) + return groups + + @staticmethod + def get_user_groups(username): + groups = [] + ret = IPBoardManager.exec_xmlrpc('getUserGroups', username=username) + for group in ret: + groups.append(group["g_title"]) + return groups + + @staticmethod + def add_group(group): + ret = IPBoardManager.exec_xmlrpc('addGroup', group=group) + return ret + + @staticmethod + def add_user_to_group(username, group): + ret = IPBoardManager.exec_xmlrpc('addUserToGroup', username=username, group=group) + return ret + + @staticmethod + def remove_user_from_group(username, group): + ret = IPBoardManager.exec_xmlrpc('removeUserFromGroup', username=username, group=group) + return ret + + @staticmethod + def help_me(): + "Random help me" + ret = IPBoardManager.exec_xmlrpc('helpMe') + return ret + + @staticmethod + def update_groups(username, groups): + + forum_groups = IPBoardManager.get_all_groups() + user_groups = set(IPBoardManager.get_user_groups(username)) + act_groups = set([g.replace(' ', '-') for g in groups]) + addgroups = act_groups - user_groups + remgroups = user_groups - act_groups + + print addgroups + print remgroups + for g in addgroups: + if not g in forum_groups: + IPBoardManager.add_group(g) + print username + print g + IPBoardManager.add_user_to_group(username, g) + + for g in remgroups: + IPBoardManager.remove_user_from_group(username, g) + + @staticmethod + def update_user_password(username, email): + plain_password = IPBoardManager.__generate_random_pass() + IPBoardManager.update_user(username, email, plain_password) + return plain_password \ No newline at end of file diff --git a/services/managers/jabber_manager.py b/services/managers/openfire_manager.py old mode 100644 new mode 100755 similarity index 94% rename from services/managers/jabber_manager.py rename to services/managers/openfire_manager.py index 501278e6..43b192d7 --- a/services/managers/jabber_manager.py +++ b/services/managers/openfire_manager.py @@ -11,7 +11,7 @@ from openfire import UserService from authentication.managers import AuthServicesInfoManager -class JabberManager: +class OpenfireManager: def __init__(self): pass @@ -35,8 +35,8 @@ class JabberManager: def add_user(username): try: - sanatized_username = JabberManager.__santatize_username(username) - password = JabberManager.__generate_random_pass() + sanatized_username = OpenfireManager.__santatize_username(username) + password = OpenfireManager.__generate_random_pass() api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY) api.add_user(sanatized_username, password) @@ -68,7 +68,7 @@ class JabberManager: @staticmethod def update_user_pass(username): try: - password = JabberManager.__generate_random_pass() + password = OpenfireManager.__generate_random_pass() api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY) api.update_user(username, password) return password diff --git a/services/managers/forum_manager.py b/services/managers/phpbb3_manager.py old mode 100644 new mode 100755 similarity index 66% rename from services/managers/forum_manager.py rename to services/managers/phpbb3_manager.py index dcea529f..5458e72a --- a/services/managers/forum_manager.py +++ b/services/managers/phpbb3_manager.py @@ -6,7 +6,7 @@ from passlib.apps import phpbb3_context from django.db import connections -class ForumManager: +class Phpbb3Manager: SQL_ADD_USER = r"INSERT INTO phpbb_users (username, username_clean, " \ r"user_password, user_email, group_id, user_regdate, user_permissions, " \ r"user_sig, user_occ, user_interests) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" @@ -52,7 +52,7 @@ class ForumManager: @staticmethod def __get_group_id(groupname): cursor = connections['phpbb3'].cursor() - cursor.execute(ForumManager.SQL_GET_GROUP_ID, [groupname]) + cursor.execute(Phpbb3Manager.SQL_GET_GROUP_ID, [groupname]) row = cursor.fetchone() return row[0] @@ -60,14 +60,14 @@ class ForumManager: @staticmethod def __get_user_id(username): cursor = connections['phpbb3'].cursor() - cursor.execute(ForumManager.SQL_USER_ID_FROM_USERNAME, [username]) + cursor.execute(Phpbb3Manager.SQL_USER_ID_FROM_USERNAME, [username]) row = cursor.fetchone() return row[0] @staticmethod def __get_all_groups(): cursor = connections['phpbb3'].cursor() - cursor.execute(ForumManager.SQL_GET_ALL_GROUPS) + cursor.execute(Phpbb3Manager.SQL_GET_ALL_GROUPS) rows = cursor.fetchall() out = {} for row in rows: @@ -78,7 +78,7 @@ class ForumManager: @staticmethod def __get_user_groups(userid): cursor = connections['phpbb3'].cursor() - cursor.execute(ForumManager.SQL_GET_USER_GROUPS, [userid]) + cursor.execute(Phpbb3Manager.SQL_GET_USER_GROUPS, [userid]) return [row[0] for row in cursor.fetchall()] @staticmethod @@ -90,37 +90,37 @@ class ForumManager: @staticmethod def __create_group(groupname): cursor = connections['phpbb3'].cursor() - cursor.execute(ForumManager.SQL_ADD_GROUP, [groupname, groupname]) - return ForumManager.__get_group_id(groupname) + cursor.execute(Phpbb3Manager.SQL_ADD_GROUP, [groupname, groupname]) + return Phpbb3Manager.__get_group_id(groupname) @staticmethod def __add_user_to_group(userid, groupid): cursor = connections['phpbb3'].cursor() - cursor.execute(ForumManager.SQL_ADD_USER_GROUP, [groupid, userid, 0]) + cursor.execute(Phpbb3Manager.SQL_ADD_USER_GROUP, [groupid, userid, 0]) @staticmethod def __remove_user_from_group(userid, groupid): cursor = connections['phpbb3'].cursor() - cursor.execute(ForumManager.SQL_REMOVE_USER_GROUP, [userid, groupid]) + cursor.execute(Phpbb3Manager.SQL_REMOVE_USER_GROUP, [userid, groupid]) @staticmethod def add_user(username, email, groups): cursor = connections['phpbb3'].cursor() - username_clean = ForumManager.__santatize_username(username) - password = ForumManager.__generate_random_pass() - pwhash = ForumManager.__gen_hash(password) + username_clean = Phpbb3Manager.__santatize_username(username) + password = Phpbb3Manager.__generate_random_pass() + pwhash = Phpbb3Manager.__gen_hash(password) # check if the username was simply revoked - if ForumManager.check_user(username_clean): - ForumManager.__update_user_info(username_clean, email, pwhash) + if Phpbb3Manager.check_user(username_clean): + Phpbb3Manager.__update_user_info(username_clean, email, pwhash) else: try: - cursor.execute(ForumManager.SQL_ADD_USER, [username_clean, username_clean, pwhash, - email, 2, ForumManager.__get_current_utc_date(), + cursor.execute(Phpbb3Manager.SQL_ADD_USER, [username_clean, username_clean, pwhash, + email, 2, Phpbb3Manager.__get_current_utc_date(), "", "", "", ""]) - ForumManager.update_groups(username_clean, groups) + Phpbb3Manager.update_groups(username_clean, groups) except: pass @@ -130,11 +130,11 @@ class ForumManager: def disable_user(username): cursor = connections['phpbb3'].cursor() - password = ForumManager.__gen_hash(ForumManager.__generate_random_pass()) + password = Phpbb3Manager.__gen_hash(Phpbb3Manager.__generate_random_pass()) revoke_email = "revoked@the99eve.com" try: - pwhash = ForumManager.__gen_hash(password) - cursor.execute(ForumManager.SQL_DIS_USER, [revoke_email, pwhash, username]) + pwhash = Phpbb3Manager.__gen_hash(password) + cursor.execute(Phpbb3Manager.SQL_DIS_USER, [revoke_email, pwhash, username]) return True except TypeError as e: print e @@ -144,16 +144,16 @@ class ForumManager: def delete_user(username): cursor = connections['phpbb3'].cursor() - if ForumManager.check_user(username): - cursor.execute(ForumManager.SQL_DEL_USER, [username]) + if Phpbb3Manager.check_user(username): + cursor.execute(Phpbb3Manager.SQL_DEL_USER, [username]) return True return False @staticmethod def update_groups(username, groups): - userid = ForumManager.__get_user_id(username) - forum_groups = ForumManager.__get_all_groups() - user_groups = set(ForumManager.__get_user_groups(userid)) + userid = Phpbb3Manager.__get_user_id(username) + forum_groups = Phpbb3Manager.__get_all_groups() + user_groups = set(Phpbb3Manager.__get_user_groups(userid)) act_groups = set([g.replace(' ', '-') for g in groups]) addgroups = act_groups - user_groups remgroups = user_groups - act_groups @@ -162,28 +162,28 @@ class ForumManager: print remgroups for g in addgroups: if not g in forum_groups: - forum_groups[g] = ForumManager.__create_group(g) - ForumManager.__add_user_to_group(userid, forum_groups[g]) + forum_groups[g] = Phpbb3Manager.__create_group(g) + Phpbb3Manager.__add_user_to_group(userid, forum_groups[g]) for g in remgroups: - ForumManager.__remove_user_from_group(userid, forum_groups[g]) + Phpbb3Manager.__remove_user_from_group(userid, forum_groups[g]) @staticmethod def remove_group(username, group): cursor = connections['phpbb3'].cursor() - userid = ForumManager.__get_user_id(username) - groupid = ForumManager.__get_group_id(group) + userid = Phpbb3Manager.__get_user_id(username) + groupid = Phpbb3Manager.__get_group_id(group) if userid: if groupid: - cursor.execute(ForumManager.SQL_REMOVE_USER_GROUP, [userid, groupid]) + cursor.execute(Phpbb3Manager.SQL_REMOVE_USER_GROUP, [userid, groupid]) @staticmethod def check_user(username): cursor = connections['phpbb3'].cursor() """ Check if the username exists """ - cursor.execute(ForumManager.SQL_USER_ID_FROM_USERNAME, [ForumManager.__santatize_username(username)]) + cursor.execute(Phpbb3Manager.SQL_USER_ID_FROM_USERNAME, [Phpbb3Manager.__santatize_username(username)]) row = cursor.fetchone() if row: return True @@ -192,10 +192,10 @@ class ForumManager: @staticmethod def update_user_password(username): cursor = connections['phpbb3'].cursor() - password = ForumManager.__generate_random_pass() - if ForumManager.check_user(username): - pwhash = ForumManager.__gen_hash(password) - cursor.execute(ForumManager.SQL_UPDATE_USER_PASSWORD, [pwhash, username]) + password = Phpbb3Manager.__generate_random_pass() + if Phpbb3Manager.check_user(username): + pwhash = Phpbb3Manager.__gen_hash(password) + cursor.execute(Phpbb3Manager.SQL_UPDATE_USER_PASSWORD, [pwhash, username]) return password return "" @@ -204,6 +204,6 @@ class ForumManager: def __update_user_info(username, email, password): cursor = connections['phpbb3'].cursor() try: - cursor.execute(ForumManager.SQL_DIS_USER, [email, password, username]) + cursor.execute(Phpbb3Manager.SQL_DIS_USER, [email, password, username]) except: pass \ No newline at end of file diff --git a/services/views.py b/services/views.py old mode 100644 new mode 100755 index 8c4c5113..64e35eb0 --- a/services/views.py +++ b/services/views.py @@ -4,17 +4,21 @@ from django.shortcuts import render_to_response from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import permission_required -from managers.jabber_manager import JabberManager -from managers.forum_manager import ForumManager +from managers.openfire_manager import OpenfireManager +from managers.phpbb3_manager import Phpbb3Manager from managers.mumble_manager import MumbleManager +from managers.ipboard_manager import IPBoardManager from authentication.managers import AuthServicesInfoManager from eveonline.managers import EveManager from celerytask.tasks import update_jabber_groups from celerytask.tasks import update_mumble_groups from celerytask.tasks import update_forum_groups +from celerytask.tasks import update_ipboard_groups from forms import JabberBroadcastForm from forms import FleetFormatterForm +from django.contrib.auth.decorators import user_passes_test +from util import check_if_user_has_permission @login_required def fleet_formatter_view(request): @@ -49,7 +53,7 @@ def jabber_broadcast_view(request): if request.method == 'POST': form = JabberBroadcastForm(request.POST) if form.is_valid(): - JabberManager.send_broadcast_message(form.cleaned_data['group'], form.cleaned_data['message']) + OpenfireManager.send_broadcast_message(form.cleaned_data['group'], form.cleaned_data['message']) success = True else: form = JabberBroadcastForm() @@ -66,13 +70,17 @@ def services_view(request): context_instance=RequestContext(request)) +def service_blue_alliance_test(user): + return check_if_user_has_permission(user, 'alliance_member') or check_if_user_has_permission(user, 'blue_member') + + @login_required -@permission_required('auth.alliance_member') +@user_passes_test(service_blue_alliance_test) def activate_forum(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) # Valid now we get the main characters character = EveManager.get_character_by_id(authinfo.main_char_id) - result = ForumManager.add_user(character.character_name, request.user.email, ['REGISTERED']) + result = Phpbb3Manager.add_user(character.character_name, request.user.email, ['REGISTERED']) # if empty we failed if result[0] != "": AuthServicesInfoManager.update_user_forum_info(result[0], result[1], request.user) @@ -82,74 +90,73 @@ def activate_forum(request): @login_required -@permission_required('auth.blue_member') -def activate_blue_forum(request): +@user_passes_test(service_blue_alliance_test) +def deactivate_forum(request): + authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) + result = Phpbb3Manager.disable_user(authinfo.forum_username) + # false we failed + if result: + AuthServicesInfoManager.update_user_forum_info("", "", request.user) + return HttpResponseRedirect("/services/") + return HttpResponseRedirect("/dashboard") + + +@login_required +@user_passes_test(service_blue_alliance_test) +def reset_forum_password(request): + authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) + result = Phpbb3Manager.update_user_password(authinfo.forum_username) + # false we failed + if result != "": + AuthServicesInfoManager.update_user_forum_info(authinfo.forum_username, result, request.user) + return HttpResponseRedirect("/services/") + return HttpResponseRedirect("/dashboard") + + +@login_required +@user_passes_test(service_blue_alliance_test) +def activate_ipboard_forum(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) # Valid now we get the main characters character = EveManager.get_character_by_id(authinfo.main_char_id) - result = ForumManager.add_user(character.character_name, request.user.email, ['REGISTERED']) - # if empty we failed + result = IPBoardManager.add_user(character.character_name, request.user.email) if result[0] != "": - AuthServicesInfoManager.update_user_forum_info(result[0], result[1], request.user) - update_forum_groups(request.user) + AuthServicesInfoManager.update_user_ipboard_info(result[0], result[1], request.user) + update_ipboard_groups(request.user) return HttpResponseRedirect("/services/") return HttpResponseRedirect("/dashboard") @login_required -@permission_required('auth.alliance_member') -def deactivate_forum(request): +@user_passes_test(service_blue_alliance_test) +def deactivate_ipboard_forum(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - result = ForumManager.disable_user(authinfo.forum_username) + result = IPBoardManager.disable_user(authinfo.ipboard_username) # false we failed if result: - AuthServicesInfoManager.update_user_forum_info("", "", request.user) + AuthServicesInfoManager.update_user_ipboard_info("", "", request.user) return HttpResponseRedirect("/services/") return HttpResponseRedirect("/dashboard") @login_required -@permission_required('auth.blue_member') -def deactivate_blue_forum(request): +@user_passes_test(service_blue_alliance_test) +def reset_ipboard_password(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - result = ForumManager.disable_user(authinfo.forum_username) - # false we failed - if result: - AuthServicesInfoManager.update_user_forum_info("", "", request.user) - return HttpResponseRedirect("/services/") - return HttpResponseRedirect("/dashboard") - - -@login_required -@permission_required('auth.alliance_member') -def reset_forum_password(request): - authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - result = ForumManager.update_user_password(authinfo.forum_username) - # false we failed + result = IPBoardManager.update_user_password(authinfo.ipboard_username, request.user.email) if result != "": - AuthServicesInfoManager.update_user_forum_info(authinfo.forum_username, result, request.user) + AuthServicesInfoManager.update_user_ipboard_info(authinfo.ipboard_username, result, request.user) return HttpResponseRedirect("/services/") return HttpResponseRedirect("/dashboard") -@login_required -@permission_required('auth.blue_member') -def reset_blue_forum_password(request): - authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - result = ForumManager.update_user_password(authinfo.forum_username) - # false we failed - if result != "": - AuthServicesInfoManager.update_user_forum_info(authinfo.forum_username, result, request.user) - return HttpResponseRedirect("/services/") - return HttpResponseRedirect("/dashboard") - @login_required -@permission_required('auth.alliance_member') +@user_passes_test(service_blue_alliance_test) def activate_jabber(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) character = EveManager.get_character_by_id(authinfo.main_char_id) - info = JabberManager.add_user(character.character_name) + info = OpenfireManager.add_user(character.character_name) # If our username is blank means we already had a user if info[0] is not "": AuthServicesInfoManager.update_user_jabber_info(info[0], info[1], request.user) @@ -159,24 +166,10 @@ def activate_jabber(request): @login_required -@permission_required('auth.blue_member') -def activate_blue_jabber(request): - authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - character = EveManager.get_character_by_id(authinfo.main_char_id) - info = JabberManager.add_user(character.character_name) - # If our username is blank means we already had a user - if info[0] is not "": - AuthServicesInfoManager.update_user_jabber_info(info[0], info[1], request.user) - update_jabber_groups(request.user) - return HttpResponseRedirect("/services/") - return HttpResponseRedirect("/dashboard") - - -@login_required -@permission_required('auth.alliance_member') +@user_passes_test(service_blue_alliance_test) def deactivate_jabber(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - result = JabberManager.delete_user(authinfo.jabber_username) + result = OpenfireManager.delete_user(authinfo.jabber_username) # If our username is blank means we failed if result: AuthServicesInfoManager.update_user_jabber_info("", "", request.user) @@ -185,22 +178,10 @@ def deactivate_jabber(request): @login_required -@permission_required('auth.blue_member') -def deactivate_blue_jabber(request): - authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - result = JabberManager.delete_user(authinfo.jabber_username) - # If our username is blank means we failed - if result: - AuthServicesInfoManager.update_user_jabber_info("", "", request.user) - return HttpResponseRedirect("/services/") - return HttpResponseRedirect("/dashboard") - - -@login_required -@permission_required('auth.alliance_member') +@user_passes_test(service_blue_alliance_test) def reset_jabber_password(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - result = JabberManager.update_user_pass(authinfo.jabber_username) + result = OpenfireManager.update_user_pass(authinfo.jabber_username) # If our username is blank means we failed if result != "": AuthServicesInfoManager.update_user_jabber_info(authinfo.jabber_username, result, request.user) @@ -209,23 +190,14 @@ def reset_jabber_password(request): @login_required -@permission_required('auth.blue_member') -def reset_blue_jabber_password(request): - authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - result = JabberManager.update_user_pass(authinfo.jabber_username) - # If our username is blank means we failed - if result != "": - AuthServicesInfoManager.update_user_jabber_info(authinfo.jabber_username, result, request.user) - return HttpResponseRedirect("/services/") - return HttpResponseRedirect("/dashboard") - - -@login_required -@permission_required('auth.alliance_member') +@user_passes_test(service_blue_alliance_test) def activate_mumble(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) character = EveManager.get_character_by_id(authinfo.main_char_id) - result = MumbleManager.create_user(character.corporation_ticker, character.character_name) + if check_if_user_has_permission(request.user, "blue_member"): + result = MumbleManager.create_blue_user(character.corporation_ticker, character.character_name) + else: + result = MumbleManager.create_user(character.corporation_ticker, character.character_name) # if its empty we failed if result[0] is not "": AuthServicesInfoManager.update_user_mumble_info(result[0], result[1], request.user) @@ -235,21 +207,7 @@ def activate_mumble(request): @login_required -@permission_required('auth.blue_member') -def activate_blue_mumble(request): - authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - character = EveManager.get_character_by_id(authinfo.main_char_id) - result = MumbleManager.create_blue_user(character.corporation_ticker, character.character_name) - # if its empty we failed - if result[0] is not "": - AuthServicesInfoManager.update_user_mumble_info(result[0], result[1], request.user) - update_mumble_groups(request.user) - return HttpResponseRedirect("/services/") - return HttpResponseRedirect("/dashboard") - - -@login_required -@permission_required('auth.alliance_member') +@user_passes_test(service_blue_alliance_test) def deactivate_mumble(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) result = MumbleManager.delete_user(authinfo.mumble_username) @@ -261,19 +219,7 @@ def deactivate_mumble(request): @login_required -@permission_required('auth.blue_member') -def deactivate_blue_mumble(request): - authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - result = MumbleManager.delete_user(authinfo.mumble_username) - # if false we failed - if result: - AuthServicesInfoManager.update_user_mumble_info("", "", request.user) - return HttpResponseRedirect("/services/") - return HttpResponseRedirect("/") - - -@login_required -@permission_required('auth.alliance_member') +@user_passes_test(service_blue_alliance_test) def reset_mumble_password(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) result = MumbleManager.update_user_password(authinfo.mumble_username) @@ -282,15 +228,3 @@ def reset_mumble_password(request): AuthServicesInfoManager.update_user_mumble_info(authinfo.mumble_username, result, request.user) return HttpResponseRedirect("/services/") return HttpResponseRedirect("/") - - -@login_required -@permission_required('auth.blue_member') -def reset_blue_mumble_password(request): - authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) - result = MumbleManager.update_user_password(authinfo.mumble_username) - # if blank we failed - if result != "": - AuthServicesInfoManager.update_user_mumble_info(authinfo.mumble_username, result, request.user) - return HttpResponseRedirect("/services/") - return HttpResponseRedirect("/") diff --git a/templates/registered/addtimer.html b/templates/registered/addtimer.html index cab9a03b..80267e5a 100755 --- a/templates/registered/addtimer.html +++ b/templates/registered/addtimer.html @@ -1,42 +1,42 @@ -{% extends "public/base.html" %} -{% load bootstrap %} -{% load staticfiles %} - -{% block title %}Alliance Auth - Timer Create{% endblock %} - -{% block page_title %}Timer Create{% endblock page_title %} -{% block extra_css %} - {% endblock extra_css %} - -{% block content %} -
-

Create Timer

- -
-
-
- {% if success %} - - {% else %} - - {% endif %} -
-
-
-
- -{% endblock content %} - -{% block extra_script %} - - $('#id_eve_time').datetimepicker({ - maskInput: true, - format: 'Y-m-d H:i',minDate:0 - }); - -{% endblock extra_script %} +{% extends "public/base.html" %} +{% load bootstrap %} +{% load staticfiles %} + +{% block title %}Alliance Auth - Timer Create{% endblock %} + +{% block page_title %}Timer Create{% endblock page_title %} +{% block extra_css %} + {% endblock extra_css %} + +{% block content %} +
+

Create Timer

+ +
+
+
+ {% if success %} + + {% else %} + + {% endif %} +
+
+
+
+ +{% endblock content %} + +{% block extra_script %} + + $('#id_eve_time').datetimepicker({ + maskInput: true, + format: 'Y-m-d H:i',minDate:0 + }); + +{% endblock extra_script %} diff --git a/templates/registered/services.html b/templates/registered/services.html old mode 100644 new mode 100755 index 659f6846..f61b3c52 --- a/templates/registered/services.html +++ b/templates/registered/services.html @@ -25,16 +25,39 @@ {{ FORUM_URL }} {% ifequal authinfo.forum_username "" %} - + {% else %} - + - + + + + {% endifequal %} + + {% endif %} + {% if ENABLE_BLUE_IPBOARD %} + IPBoard Forums + {{ authinfo.ipboard_username }} + {{ authinfo.ipboard_password }} + {{ FORUM_URL }} + + {% ifequal authinfo.ipboard_username "" %} + + + + {% else %} + + + + @@ -49,16 +72,16 @@ {{ JABBER_URL }} {% ifequal authinfo.jabber_username "" %} - + {% else %} - + - + @@ -74,16 +97,16 @@ {{ MUMBLE_URL }} {% ifequal authinfo.mumble_username "" %} - + {% else %} - + - + @@ -126,6 +149,29 @@ {% endif %} + {% if ENABLE_ALLIANCE_IPBOARD %} + IPBoard Forums + {{ authinfo.ipboard_username }} + {{ authinfo.ipboard_password }} + {{ FORUM_URL }} + + {% ifequal authinfo.ipboard_username "" %} + + + + {% else %} + + + + + + + {% endifequal %} + + {% endif %} {% if ENABLE_ALLIANCE_JABBER %} Jabber diff --git a/templates/registered/timermanagement.html b/templates/registered/timermanagement.html index 3726fcdd..5ffacbcf 100755 --- a/templates/registered/timermanagement.html +++ b/templates/registered/timermanagement.html @@ -1,211 +1,211 @@ -{% extends "public/base.html" %} -{% load staticfiles %} - -{% block title %}Alliance Auth{% endblock %} - -{% block page_title %}Timer Management{% endblock page_title %} -{% block extra_css %}{% endblock extra_css %} - -{% block content %} -
-

Operation Timers - -

-
-
- Current Eve Time: {{ CURRENT_UTC_TIME | date:"Y-m-d H:i" }} -
-
-

Next Timer

- - - - - - - - - {% if perms.auth.timer_management %} - - {% endif %} - - {% if closest_timer %} - {% ifequal closest_timer.important True %} - - {% else %} - - {% endifequal %} - - - - - - - {% if perms.auth.timer_management %} - - {% endif %} - {% endif %} - -
Fleet NameFleet TypeSystemStructureEve TimeCreatorAction
{{ closest_timer.name }} - {% ifequal closest_timer.fleet_type "Armor" %} -
- Armor -
- {% endifequal %} - {% ifequal closest_timer.fleet_type "Shield" %} -
- Shield -
- {% endifequal %} - {% ifequal closest_timer.fleet_type "Other" %} -
- Other -
- {% endifequal %} -
{{ closest_timer.system }} {{ closest_timer.planet_moon }} - - {% ifequal closest_timer.structure "I-HUB" %} -
- I-HUB -
- {% endifequal %} - {% ifequal closest_timer.structure "POCO" %} -
- POCO -
- {% endifequal %} - {% ifequal closest_timer.structure "POS[S]" %} -
- POS [S] -
- {% endifequal %} - {% ifequal closest_timer.structure "POS[M]" %} -
- POS [M] -
- {% endifequal %} - {% ifequal closest_timer.structure "POS[L]" %} -
- POS [L] -
- {% endifequal %} - {% ifequal closest_timer.structure "Station" %} -
- Station -
- {% endifequal %} - {% ifequal closest_timer.structure "Other" %} -
- Other -
- {% endifequal %} -
{{ closest_timer.eve_time | date:"Y-m-d H:i" }} UTC{{ closest_timer.eve_character.character_name }} - - - - -
- -

Future Timers

- - - - - - - - - {% if perms.auth.timer_management %} - - {% endif %} - - {% for timer in timers %} - {% ifnotequal timer closest_timer %} - {% ifequal timer.important True %} - - {% else %} - - {% endifequal %} - - - - - - - {% if perms.auth.timer_management %} - - {% endif %} - - {% endifnotequal %} - {% endfor %} -
Fleet NameFleet TypeSystemStructureEve TimeCreatorAction
{{ timer.name }} - {% ifequal timer.fleet_type "Armor" %} -
- Armor -
- {% endifequal %} - {% ifequal timer.fleet_type "Shield" %} -
- Shield -
- {% endifequal %} - {% ifequal timer.fleet_type "Other" %} -
- Other -
- {% endifequal %} -
{{ timer.system }} {{ timer.planet_moon }} - - {% ifequal timer.structure "I-HUB" %} -
- I-HUB -
- {% endifequal %} - {% ifequal timer.structure "POCO" %} -
- POCO -
- {% endifequal %} - {% ifequal timer.structure "POS[S]" %} -
- POS [S] -
- {% endifequal %} - {% ifequal timer.structure "POS[M]" %} -
- POS [M] -
- {% endifequal %} - {% ifequal timer.structure "POS[L]" %} -
- POS [L] -
- {% endifequal %} - {% ifequal timer.structure "Station" %} -
- Station -
- {% endifequal %} - {% ifequal timer.structure "Other" %} -
- Other -
- {% endifequal %} -
{{ timer.eve_time | date:"Y-m-d H:i" }} UTC{{ timer.eve_character.character_name }} - - - -
-
- -{% endblock content %} +{% extends "public/base.html" %} +{% load staticfiles %} + +{% block title %}Alliance Auth{% endblock %} + +{% block page_title %}Timer Management{% endblock page_title %} +{% block extra_css %}{% endblock extra_css %} + +{% block content %} +
+

Operation Timers + +

+
+
+ Current Eve Time: {{ CURRENT_UTC_TIME | date:"Y-m-d H:i" }} +
+
+

Next Timer

+ + + + + + + + + {% if perms.auth.timer_management %} + + {% endif %} + + {% if closest_timer %} + {% ifequal closest_timer.important True %} + + {% else %} + + {% endifequal %} + + + + + + + {% if perms.auth.timer_management %} + + {% endif %} + {% endif %} + +
Fleet NameFleet TypeSystemStructureEve TimeCreatorAction
{{ closest_timer.name }} + {% ifequal closest_timer.fleet_type "Armor" %} +
+ Armor +
+ {% endifequal %} + {% ifequal closest_timer.fleet_type "Shield" %} +
+ Shield +
+ {% endifequal %} + {% ifequal closest_timer.fleet_type "Other" %} +
+ Other +
+ {% endifequal %} +
{{ closest_timer.system }} {{ closest_timer.planet_moon }} + + {% ifequal closest_timer.structure "I-HUB" %} +
+ I-HUB +
+ {% endifequal %} + {% ifequal closest_timer.structure "POCO" %} +
+ POCO +
+ {% endifequal %} + {% ifequal closest_timer.structure "POS[S]" %} +
+ POS [S] +
+ {% endifequal %} + {% ifequal closest_timer.structure "POS[M]" %} +
+ POS [M] +
+ {% endifequal %} + {% ifequal closest_timer.structure "POS[L]" %} +
+ POS [L] +
+ {% endifequal %} + {% ifequal closest_timer.structure "Station" %} +
+ Station +
+ {% endifequal %} + {% ifequal closest_timer.structure "Other" %} +
+ Other +
+ {% endifequal %} +
{{ closest_timer.eve_time | date:"Y-m-d H:i" }} UTC{{ closest_timer.eve_character.character_name }} + + + + +
+ +

Future Timers

+ + + + + + + + + {% if perms.auth.timer_management %} + + {% endif %} + + {% for timer in timers %} + {% ifnotequal timer closest_timer %} + {% ifequal timer.important True %} + + {% else %} + + {% endifequal %} + + + + + + + {% if perms.auth.timer_management %} + + {% endif %} + + {% endifnotequal %} + {% endfor %} +
Fleet NameFleet TypeSystemStructureEve TimeCreatorAction
{{ timer.name }} + {% ifequal timer.fleet_type "Armor" %} +
+ Armor +
+ {% endifequal %} + {% ifequal timer.fleet_type "Shield" %} +
+ Shield +
+ {% endifequal %} + {% ifequal timer.fleet_type "Other" %} +
+ Other +
+ {% endifequal %} +
{{ timer.system }} {{ timer.planet_moon }} + + {% ifequal timer.structure "I-HUB" %} +
+ I-HUB +
+ {% endifequal %} + {% ifequal timer.structure "POCO" %} +
+ POCO +
+ {% endifequal %} + {% ifequal timer.structure "POS[S]" %} +
+ POS [S] +
+ {% endifequal %} + {% ifequal timer.structure "POS[M]" %} +
+ POS [M] +
+ {% endifequal %} + {% ifequal timer.structure "POS[L]" %} +
+ POS [L] +
+ {% endifequal %} + {% ifequal timer.structure "Station" %} +
+ Station +
+ {% endifequal %} + {% ifequal timer.structure "Other" %} +
+ Other +
+ {% endifequal %} +
{{ timer.eve_time | date:"Y-m-d H:i" }} UTC{{ timer.eve_character.character_name }} + + + +
+
+ +{% endblock content %} diff --git a/thirdparty/IPBoard3/Readme.txt b/thirdparty/IPBoard3/Readme.txt new file mode 100755 index 00000000..40ed0370 --- /dev/null +++ b/thirdparty/IPBoard3/Readme.txt @@ -0,0 +1,2 @@ +To utilize this module copy the folder "aa" to your interface/board/modules/ directory. +Then create and api key and give all "AllianceAuth" permissions to it. \ No newline at end of file diff --git a/thirdparty/IPBoard3/aa/api.php b/thirdparty/IPBoard3/aa/api.php new file mode 100755 index 00000000..86e01088 --- /dev/null +++ b/thirdparty/IPBoard3/aa/api.php @@ -0,0 +1,526 @@ +registry = $registry; + + //----------------------------------------- + // Load allowed methods and build dispatch + // list + //----------------------------------------- + $ALLOWED_METHODS = array(); + require_once( DOC_IPS_ROOT_PATH . 'interface/board/modules/aa/methods.php' );/*noLibHook*/ + + if ( is_array( $ALLOWED_METHODS ) and count( $ALLOWED_METHODS ) ) + { + foreach( $ALLOWED_METHODS as $_method => $_data ) + { + $this->__dispatch_map[ $_method ] = $_data; + } + } + } + + // Creates a new user + public function createUser( $api_key, $api_module, $username, $email, $display_name, $md5_passwordHash) + { + //----------------------------------------- + // INIT + //----------------------------------------- + + $api_key = IPSText::md5Clean( $api_key ); + $api_module = IPSText::parseCleanValue( $api_module ); + + //----------------------------------------- + // Authenticate + //----------------------------------------- + + if ( $this->__authenticate( $api_key, $api_module, 'createUser' ) !== FALSE ) + { + + //----------------------------------------- + // Add log + //----------------------------------------- + $this->addLogging( $api_key ); + + //----------------------------------------- + // Create a user + //----------------------------------------- + $test = IPSMember::create( array( 'core' => array( 'email' => $email, 'md5_hash_password' => $md5_passwordHash, 'name' => $username, 'members_display_name' => $display_name) ) ); + + //----------------------------------------- + // The way IPSMember::create function works is it can't fail.. It always returns true unless all data isn't provided. + // However it will still create a partial record. So in essence never fails + //----------------------------------------- + $this->classApiServer->apiSendReply( array('result' => 'success') ); + + exit(); + } + } + + + // Deletes a user from the entire system + public function deleteUser( $api_key, $api_module, $username) + { + //----------------------------------------- + // INIT + //----------------------------------------- + + $api_key = IPSText::md5Clean( $api_key ); + $api_module = IPSText::parseCleanValue( $api_module ); + + //----------------------------------------- + // Authenticate + //----------------------------------------- + + if ( $this->__authenticate( $api_key, $api_module, 'deleteUser' ) !== FALSE ) + { + + //----------------------------------------- + // Add log + //----------------------------------------- + $this->addLogging( $api_key ); + + //----------------------------------------- + // Remove a user by username + //----------------------------------------- + $member = IPSMember::load($username,'all','username'); + + if ($member != null) { + $result = IPSMember::remove($member['member_id']); + + if($result) { + $this->classApiServer->apiSendReply( array('result' => 'success') ); + } else { + $this->classApiServer->apiSendReply( array('result' => 'failure') ); + } + } + + $this->classApiServer->apiSendReply( array('result' => 'failure') ); + + exit(); + } + } + + // We disable by just changing the email and password to something random. + // Allows us to avoid losing post etc. + public function disableUser( $api_key, $api_module, $username) + { + //----------------------------------------- + // INIT + //----------------------------------------- + + $api_key = IPSText::md5Clean( $api_key ); + $api_module = IPSText::parseCleanValue( $api_module ); + + //----------------------------------------- + // Authenticate + //----------------------------------------- + + if ( $this->__authenticate( $api_key, $api_module, 'disableUser' ) !== FALSE ) + { + + //----------------------------------------- + // Add log + //----------------------------------------- + $this->addLogging( $api_key ); + + //----------------------------------------- + // Remove a user by username + //----------------------------------------- + $member = IPSMember::load($username,'all','username'); + + if ($member != null) { + + $uniqueID = strval(uniqid()); + $uniqueEmail = strval(uniqid()); + $uniqueMD5 = md5($uniqueID); + $email = $uniqueEmail.'@'.$uniqueEmail.'.com'; + + $email_result = IPSMember::save( array( 'core' => array( 'field' => 'member_id', 'value' => $member['member_id'])),array('core' => array('email'=>$email))); + $password_result = $password_result = IPSMember::updatePassword($member['member_id'], $uniqueMD5); + + if($email_result && $password_result) { + $this->classApiServer->apiSendReply( array('result' => 'success') ); + } else { + $this->classApiServer->apiSendReply( array('result' => 'failure') ); + } + } + + $this->classApiServer->apiSendReply( array('result' => 'failure') ); + + exit(); + } + } + + // Used to update the user email, and password. + // Is also used to re-enable a disabled account + public function updateUser( $api_key, $api_module, $username, $email, $md5_passwordHash) + { + //----------------------------------------- + // INIT + //----------------------------------------- + + $api_key = IPSText::md5Clean( $api_key ); + $api_module = IPSText::parseCleanValue( $api_module ); + + //----------------------------------------- + // Authenticate + //----------------------------------------- + + if ( $this->__authenticate( $api_key, $api_module, 'updateUser' ) !== FALSE ) + { + + //----------------------------------------- + // Add log + //----------------------------------------- + $this->addLogging( $api_key ); + + //----------------------------------------- + // Load our user + //----------------------------------------- + $member = IPSMember::load($username,'all','username'); + + if ($member != null) { + + $email_result = IPSMember::save( array( 'core' => array( 'field' => 'member_id', 'value' => $member['member_id'])),array('core' => array('email'=>$email))); + $password_result = $password_result = IPSMember::updatePassword($member['member_id'], $md5_passwordHash); + + if($email_result && $password_result) { + $this->classApiServer->apiSendReply( array('result' => 'success') ); + } else { + $this->classApiServer->apiSendReply( array('result' => 'failure') ); + } + } + + $this->classApiServer->apiSendReply( array('result' => 'failure') ); + + exit(); + } + } + + public function getAllGroups( $api_key, $api_module) + { + //----------------------------------------- + // INIT + //----------------------------------------- + + $api_key = IPSText::md5Clean( $api_key ); + $api_module = IPSText::parseCleanValue( $api_module ); + + //----------------------------------------- + // Authenticate + //----------------------------------------- + + if ( $this->__authenticate( $api_key, $api_module, 'getAllGroups' ) !== FALSE ) + { + + //----------------------------------------- + // Add log + //----------------------------------------- + $this->addLogging( $api_key ); + + //----------------------------------------- + // Load our user + //----------------------------------------- + ipsRegistry::DB()->build(array('select' => 'g_title', 'from' => 'groups')); + $result = ipsRegistry::DB()->execute(); + $groups = array(); + + while( $r = ipsRegistry::DB()->fetch($result)) { + array_push($groups,$r); + } + $this->classApiServer->apiSendReply($groups); + + exit(); + } + } + + public function getUserGroups( $api_key, $api_module, $username) + { + //----------------------------------------- + // INIT + //----------------------------------------- + + $api_key = IPSText::md5Clean( $api_key ); + $api_module = IPSText::parseCleanValue( $api_module ); + + //----------------------------------------- + // Authenticate + //----------------------------------------- + + if ( $this->__authenticate( $api_key, $api_module, 'getUserGroups' ) !== FALSE ) + { + + //----------------------------------------- + // Add log + //----------------------------------------- + $this->addLogging( $api_key ); + + $member = IPSMember::load($username,'all','username'); + + if( $member['mgroup_others']) { + $groupids = explode(',' , $member['mgroup_others']); + + $groups = array(); + foreach ($groupids as &$groupid) { + ipsRegistry::DB()->build(array('select' => 'g_title', 'from'=>'groups','where'=>'g_id='.$groupid)); + $result = ipsRegistry::DB()->execute(); + array_push($groups, ipsRegistry::DB()->fetch($result)); + } + } + $this->classApiServer->apiSendReply($groups); + + exit(); + } + } + + + public function addGroup( $api_key, $api_module, $group) + { + //----------------------------------------- + // INIT + //----------------------------------------- + + $api_key = IPSText::md5Clean( $api_key ); + $api_module = IPSText::parseCleanValue( $api_module ); + + //----------------------------------------- + // Authenticate + //----------------------------------------- + + if ( $this->__authenticate( $api_key, $api_module, 'addGroup' ) !== FALSE ) + { + + //----------------------------------------- + // Add log + //----------------------------------------- + $this->addLogging( $api_key ); + + $result = ipsRegistry::DB()->insert("groups", array('g_title'=>$group)); + ipsRegistry::DB()->fetch($result); + + // Rebuild the group cache + ipsRegistry::cache()->rebuildCache( 'group_cache', 'global' ); + + // Regardless if it passes or fails it will only fail if it exist + $this->classApiServer->apiSendReply(array('result'=>'success')); + + exit(); + } + } + + public function addUserToGroup( $api_key, $api_module, $username, $group) + { + //----------------------------------------- + // INIT + //----------------------------------------- + + $api_key = IPSText::md5Clean( $api_key ); + $api_module = IPSText::parseCleanValue( $api_module ); + + //----------------------------------------- + // Authenticate + //----------------------------------------- + + if ( $this->__authenticate( $api_key, $api_module, 'addUserToGroup' ) !== FALSE ) + { + + //----------------------------------------- + // Add log + //----------------------------------------- + $this->addLogging( $api_key ); + + $member = IPSMember::load($username,'all','username'); + $groups = explode(",", $member['mgroup_others']); + + // Group group id + ipsRegistry::DB()->build(array('select' => 'g_id', 'from' => 'groups', 'where'=>"g_title='{$group}'")); + $result = ipsRegistry::DB()->execute(); + array_push($groups, ipsRegistry::DB()->fetch($result)['g_id']); + + $groupstoadd = implode(",", $groups); + IPSMember::save( array( 'core' => array( 'field' => 'member_id', 'value' => $member['member_id'])),array('core' => array('mgroup_others'=>$groupstoadd))); + + // Rebuild the group cache + ipsRegistry::cache()->rebuildCache( 'group_cache', 'global' ); + + $this->classApiServer->apiSendReply($groups); + + exit(); + } + } + + public function removeUserFromGroup( $api_key, $api_module, $username, $group) + { + //----------------------------------------- + // INIT + //----------------------------------------- + + $api_key = IPSText::md5Clean( $api_key ); + $api_module = IPSText::parseCleanValue( $api_module ); + + //----------------------------------------- + // Authenticate + //----------------------------------------- + + if ( $this->__authenticate( $api_key, $api_module, 'removeUserFromGroup' ) !== FALSE ) + { + + //----------------------------------------- + // Add log + //----------------------------------------- + $this->addLogging( $api_key ); + + $member = IPSMember::load($username,'all','username'); + $groups = explode(",", $member['mgroup_others']); + + // Group group id + ipsRegistry::DB()->build(array('select' => 'g_id', 'from' => 'groups', 'where'=>"g_title='{$group}'")); + $result = ipsRegistry::DB()->execute(); + $diffGroup = array_diff($groups, array(ipsRegistry::DB()->fetch($result)['g_id'])); + + $groupstoadd = implode(",", $diffGroup); + IPSMember::save( array( 'core' => array( 'field' => 'member_id', 'value' => $member['member_id'])),array('core' => array('mgroup_others'=>$groupstoadd))); + + // Rebuild the group cache + ipsRegistry::cache()->rebuildCache( 'group_cache', 'global' ); + + $this->classApiServer->apiSendReply($diffGroup); + + exit(); + } + } + + public function helpMe( $api_key, $api_module) + { + //----------------------------------------- + // INIT + //----------------------------------------- + + $api_key = IPSText::md5Clean( $api_key ); + $api_module = IPSText::parseCleanValue( $api_module ); + + //----------------------------------------- + // Authenticate + //----------------------------------------- + + if ( $this->__authenticate( $api_key, $api_module, 'helpMe' ) !== FALSE ) + { + + //----------------------------------------- + // Add log + //----------------------------------------- + $this->addLogging( $api_key ); + + + $this->classApiServer->apiSendReply($groups); + + exit(); + } + } + + /** + * Adds logging obviously :) + * + * @param string $api_key Authentication Key + */ + public function addLogging( $api_key ) + { + if ( ipsRegistry::$settings['xmlrpc_log_type'] != 'failed' ) + { + $this->registry->DB()->insert( 'api_log', array( 'api_log_key' => $api_key, + 'api_log_ip' => $_SERVER['REMOTE_ADDR'], + 'api_log_date' => time(), + 'api_log_query' => $this->classApiServer->raw_request, + 'api_log_allowed' => 1 ) ); + } + } + + /** + * Checks to see if the request is allowed + * + * @param string $api_key Authenticate Key + * @param string $api_module Module + * @param string $api_function Function + * @return string Error message, if any + */ + protected function __authenticate( $api_key, $api_module, $api_function ) + { + //----------------------------------------- + // Check + //----------------------------------------- + + if ( $this->api_user['api_user_id'] ) + { + $this->api_user['_permissions'] = unserialize( stripslashes( $this->api_user['api_user_perms'] ) ); + + if ( $this->api_user['_permissions'][ $api_module ][ $api_function ] == 1 ) + { + return TRUE; + } + else + { + $this->registry->DB()->insert( 'api_log', array( 'api_log_key' => $api_key, + 'api_log_ip' => $_SERVER['REMOTE_ADDR'], + 'api_log_date' => time(), + 'api_log_query' => $this->classApiServer->raw_request, + 'api_log_allowed' => 0 ) ); + + $this->classApiServer->apiSendError( '200', "API Key {$api_key} does not have permission for {$api_module}/{$api_function}" ); + + return FALSE; + } + } + else + { + $this->registry->DB()->insert( 'api_log', array( 'api_log_key' => $api_key, + 'api_log_ip' => $_SERVER['REMOTE_ADDR'], + 'api_log_date' => time(), + 'api_log_query' => $this->classApiServer->raw_request, + 'api_log_allowed' => 0 ) ); + + $this->classApiServer->apiSendError( '100', "API Key {$api_key} does not have permission for {$api_module}/{$api_function}" ); + + return FALSE; + } + } + +} \ No newline at end of file diff --git a/thirdparty/IPBoard3/aa/config.php b/thirdparty/IPBoard3/aa/config.php new file mode 100755 index 00000000..507ffb92 --- /dev/null +++ b/thirdparty/IPBoard3/aa/config.php @@ -0,0 +1,11 @@ + +IP.Board - Bulletin Board System + +

403: IP.Board -> Forbidden

+
+You have reached this page in error, please use your back button to return to the forum. +
+ + + \ No newline at end of file diff --git a/thirdparty/IPBoard3/aa/methods.php b/thirdparty/IPBoard3/aa/methods.php new file mode 100755 index 00000000..40bb166b --- /dev/null +++ b/thirdparty/IPBoard3/aa/methods.php @@ -0,0 +1,125 @@ + array( + 'api_key' => 'string', + 'api_module' => 'string', + 'username' => 'string', + 'email' => 'string', + 'display_name'=> 'string', + 'md5_passwordHash' => 'string' + ), + 'out' => array( + 'response' => 'xmlrpc' + ) + ); + +$ALLOWED_METHODS['deleteUser'] = array( + 'in' => array( + 'api_key' => 'string', + 'api_module' => 'string', + 'username' => 'string' + ), + 'out' => array( + 'response' => 'xmlrpc' + ) + ); + +$ALLOWED_METHODS['disableUser'] = array( + 'in' => array( + 'api_key' => 'string', + 'api_module' => 'string', + 'username' => 'string' + ), + 'out' => array( + 'response' => 'xmlrpc' + ) + ); + +$ALLOWED_METHODS['updateUser'] = array( + 'in' => array( + 'api_key' => 'string', + 'api_module' => 'string', + 'username' => 'string', + 'email' => 'string', + 'md5_passwordHash' => 'string' + ), + 'out' => array( + 'response' => 'xmlrpc' + ) + ); + +$ALLOWED_METHODS['getAllGroups'] = array( + 'in' => array( + 'api_key' => 'string', + 'api_module' => 'string', + ), + 'out' => array( + 'response' => 'xmlrpc' + ) + ); + +$ALLOWED_METHODS['getUserGroups'] = array( + 'in' => array( + 'api_key' => 'string', + 'api_module' => 'string', + 'username' => 'string' + ), + 'out' => array( + 'response' => 'xmlrpc' + ) + ); + +$ALLOWED_METHODS['addGroup'] = array( + 'in' => array( + 'api_key' => 'string', + 'api_module' => 'string', + 'group' => 'string' + ), + 'out' => array( + 'response' => 'xmlrpc' + ) + ); + +$ALLOWED_METHODS['addUserToGroup'] = array( + 'in' => array( + 'api_key' => 'string', + 'api_module' => 'string', + 'username' => 'string', + 'group' => 'string' + ), + 'out' => array( + 'response' => 'xmlrpc' + ) + ); + +$ALLOWED_METHODS['removeUserFromGroup'] = array( + 'in' => array( + 'api_key' => 'string', + 'api_module' => 'string', + 'username' => 'string', + 'group' => 'string' + ), + 'out' => array( + 'response' => 'xmlrpc' + ) + ); + +$ALLOWED_METHODS['helpMe'] = array( + 'in' => array( + 'api_key' => 'string', + 'api_module' => 'string', + + ), + 'out' => array( + 'response' => 'xmlrpc' + ) + ); \ No newline at end of file diff --git a/timerboard/form.py b/timerboard/form.py index 1ca7420c..f4c77e04 100755 --- a/timerboard/form.py +++ b/timerboard/form.py @@ -1,15 +1,15 @@ -from django import forms - - -class TimerForm(forms.Form): - structure_choices = [('POCO', 'POCO'), ('I-HUB', 'I-HUB'), ('POS[S]', 'POS[S]'), - ('POS[M]', 'POS[M]'), ('POS[L]', 'POS[L]'), ('Station', 'Station'), ('Other', 'Other')] - fleet_type_choices = [('Armor', 'Armor'), ('Shield', 'Shield'), ('Other', 'Other')] - - name = forms.CharField(max_length=254, required=True, label='Fleet Name') - system = forms.CharField(max_length=254, required=True, label="System") - planet_moon = forms.CharField(max_length=254, label="Planet/Moon", required=False, initial="") - structure = forms.ChoiceField(choices=structure_choices, required=True, label="Structure Type") - fleet_type = forms.ChoiceField(choices=fleet_type_choices, required=True, label="Fleet Type") - eve_time = forms.DateTimeField(required=True, label="Eve Time") +from django import forms + + +class TimerForm(forms.Form): + structure_choices = [('POCO', 'POCO'), ('I-HUB', 'I-HUB'), ('POS[S]', 'POS[S]'), + ('POS[M]', 'POS[M]'), ('POS[L]', 'POS[L]'), ('Station', 'Station'), ('Other', 'Other')] + fleet_type_choices = [('Armor', 'Armor'), ('Shield', 'Shield'), ('Other', 'Other')] + + name = forms.CharField(max_length=254, required=True, label='Fleet Name') + system = forms.CharField(max_length=254, required=True, label="System") + planet_moon = forms.CharField(max_length=254, label="Planet/Moon", required=False, initial="") + structure = forms.ChoiceField(choices=structure_choices, required=True, label="Structure Type") + fleet_type = forms.ChoiceField(choices=fleet_type_choices, required=True, label="Fleet Type") + eve_time = forms.DateTimeField(required=True, label="Eve Time") important = forms.BooleanField(label="Important", required=False) \ No newline at end of file diff --git a/util/common_task.py b/util/common_task.py old mode 100644 new mode 100755 index 42c43557..b945f834 --- a/util/common_task.py +++ b/util/common_task.py @@ -2,9 +2,10 @@ from django.contrib.auth.models import Group from django.contrib.auth.models import User from authentication.managers import AuthServicesInfoManager -from services.managers.jabber_manager import JabberManager -from services.managers.forum_manager import ForumManager +from services.managers.openfire_manager import OpenfireManager +from services.managers.phpbb3_manager import Phpbb3Manager from services.managers.mumble_manager import MumbleManager +from services.managers.ipboard_manager import IPBoardManager def add_user_to_group(user, groupname): @@ -28,10 +29,13 @@ def deactivate_services(user): MumbleManager.delete_user(authinfo.mumble_username) AuthServicesInfoManager.update_user_mumble_info("", "", user) if authinfo.jabber_username != "": - JabberManager.delete_user(authinfo.jabber_username) + OpenfireManager.delete_user(authinfo.jabber_username) AuthServicesInfoManager.update_user_jabber_info("", "", user) if authinfo.forum_username != "": - ForumManager.disable_user(authinfo.forum_username) + Phpbb3Manager.disable_user(authinfo.forum_username) + AuthServicesInfoManager.update_user_forum_info("", "", user) + if authinfo.ipboard_username != "": + IPBoardManager.disable_user(authinfo.ipboard_username) AuthServicesInfoManager.update_user_forum_info("", "", user) diff --git a/util/context_processors.py b/util/context_processors.py index ce481e4e..67c5163d 100755 --- a/util/context_processors.py +++ b/util/context_processors.py @@ -20,7 +20,9 @@ def domain_url(request): 'ENABLE_ALLIANCE_FORUM': settings.ENABLE_ALLIANCE_FORUM, 'ENABLE_ALLIANCE_JABBER': settings.ENABLE_ALLIANCE_JABBER, 'ENABLE_ALLIANCE_MUMBLE': settings.ENABLE_ALLIANCE_MUMBLE, + 'ENABLE_ALLIANCE_IPBOARD': settings.ENABLE_ALLIANCE_IPBOARD, 'ENABLE_BLUE_JABBER': settings.ENABLE_BLUE_JABBER, 'ENABLE_BLUE_FORUM': settings.ENABLE_BLUE_FORUM, 'ENABLE_BLUE_MUMBLE': settings.ENABLE_BLUE_MUMBLE, + 'ENABLE_BLUE_IPBOARD': settings.ENABLE_BLUE_IPBOARD, 'CURRENT_UTC_TIME': timezone.now()} \ No newline at end of file