diff --git a/app/classes/models/server_permissions.py b/app/classes/models/server_permissions.py index ccf81a38..a7956e0f 100644 --- a/app/classes/models/server_permissions.py +++ b/app/classes/models/server_permissions.py @@ -165,7 +165,10 @@ class Permissions_Servers: else: roles_list = users_helper.get_user_roles_id(user_id) role_server = Role_Servers.select().where(Role_Servers.role_id.in_(roles_list)).where(Role_Servers.server_id == int(server_id)).execute() - permissions_mask = role_server[0].permissions + if len(role_server) > 0: + permissions_mask = role_server[0].permissions + else: + permissions_mask = '00000000' permissions_list = server_permissions.get_permissions(permissions_mask) return permissions_list diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 6f08f622..3f5bb8cc 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -97,12 +97,16 @@ class Helpers: @staticmethod def check_port(server_port): - try: - host_public = get('https://api.ipify.org').text - tn = telnetlib.Telnet(host_public, server_port, 10) - telnetlib.close() + a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + ip = get('https://api.ipify.org').content.decode('utf8') + + location = (ip, server_port) + result_of_check = a_socket.connect_ex(location) + + if result_of_check == 0: return True - except Exception as err: + else: return False @staticmethod diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index 927d4947..46391226 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -73,7 +73,6 @@ class TasksManager: logger.info("Loading schedule ID#{i}: '{a}' every {n} {t} at {s}".format( i=j.schedule_id, a=j.action, n=j.interval, t=j.interval_type, s=j.start_time)) try: - print(self.controller.users.get_id_by_name('system')) getattr(schedule.every(j.interval), j.interval_type).at(j.start_time).do( self.controller.management.send_command, self.controller.users.get_id_by_name('system'), j.server_id, "127.27.23.89", j.action) except schedule.ScheduleValueError as e: diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 7f0c1d1c..da5bc8e9 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -469,7 +469,7 @@ class PanelHandler(BaseHandler): page_data['quantity_server'] = self.controller.crafty_perms.list_crafty_permissions_quantity_limits(user_id) page_data['languages'] = [] page_data['languages'].append(self.controller.users.get_user_lang_by_id(user_id)) - for file in os.listdir(os.path.join(helper.root_dir, 'app', 'translations')): + for file in sorted(os.listdir(os.path.join(helper.root_dir, 'app', 'translations'))): if file.endswith('.json'): if file != str(page_data['languages'][0] + '.json'): page_data['languages'].append(file.split('.')[0]) @@ -916,8 +916,9 @@ class PanelHandler(BaseHandler): elif page == "add_user": - if bleach.clean(self.get_argument('username', None)): + if bleach.clean(self.get_argument('username', None)).lower() == 'system': self.redirect("/panel/error?error=Unauthorized access: username system is reserved for the Crafty system. Please choose a different username.") + return username = bleach.clean(self.get_argument('username', None)) password0 = bleach.clean(self.get_argument('password0', None)) password1 = bleach.clean(self.get_argument('password1', None))