def get_mailbox_info(self): mysql_helper = MysqlHelper(self.da_ip, self.port, self.db_name, self.db_user, self.db_password) sql = "select * from mailbox where username='******'" % (self.mail_user) json_mailbox_info = mysql_helper.get_all(sql) for dict_mailbox_info in json_mailbox_info: if dict_mailbox_info is not None: return dict_mailbox_info else: return None
def get_admin_info(self): mysqlhelper = MysqlHelper(self.ip, self.port, self.dbname, self.dbuser, self.dbpassword) sql = "select * from administrator where username = '******'" % ( self.username) json_info = mysqlhelper.get_all(sql) for dict in json_info: if dict is not None: return dict else: return None mysqlhelper.close()
def get_domain_status(self): mysql_helper = MysqlHelper(self.ip, self.port, self.db_name, self.db_user, self.db_password) sql = 'select * from blacklist WHERE username like "%%%s%%"' % ( self.domain_name) json_data = mysql_helper.get_all(sql) for dict_data in json_data: if dict_data is not None: return dict_data else: return None mysql_helper.close()
def get_ip_status(self): mysql_helper = MysqlHelper(self.ip, self.port, self.db_name, self.db_user, self.db_password) sql = 'select * from ipblacklist where ip_address like "%%%s%%"' % ( self.ip_info) json_data = mysql_helper.get_all(sql) for dict_data in json_data: if dict_data is not None: return dict_data else: return None mysql_helper.close()
def get_da_path(self): mysql_helper = MysqlHelper(self.da_ip, self.port, self.db_name, self.db_user, self.db_password) sql = "select home from mailbox where username = '******'" % ( self.mail_user) json_da_path = mysql_helper.get_all(sql) for dict_da_path in json_da_path: if dict_da_path is not None: dict_da_path = dict_da_path['home'] str_da_ip = "".join(dict_da_path) return str_da_ip else: return None
def get_net_user_info(self): list_mail_user = self.mail_user.split('@') user_id = list_mail_user[0] domain_name = list_mail_user[1] mysql_helper = MysqlHelper(self.ip, self.port, self.db_name, self.db_user, self.db_password) sql = "select * from usersinfo where userid='%s' and domainid=(select domain_id from domain where domain_name='%s')" % ( user_id, domain_name) json_users_info = mysql_helper.get_all(sql) for dict_users_info in json_users_info: if dict_users_info is not None: return dict_users_info else: return None
def get_baseid_nfsid(self): list_mail_user = self.mail_user.split('@') user_id = list_mail_user[0] domain_name = list_mail_user[1] mysql_helper = MysqlHelper(self.ip, self.port, self.db_name, self.db_user, self.db_password) sql = "select basecdnid,nfsid from usersinfo where userid='%s' and domainid=(select domain_id from domain where domain_name='%s')" % ( user_id, domain_name) json_base_id_nf_sid = mysql_helper.get_all(sql) for dict_id in json_base_id_nf_sid: if dict_id is not None: return dict_id else: return None
def get_user_webmail_login(self): mysqlhelper = MysqlHelper(self.ip, self.port, self.db_name, self.db_user, self.db_password, charset='utf8') sql = "select login_time from USER_LOGIN_HISTORY where username='******' order by login_time desc limit 1" % ( self.mail_user) data_tuple = mysqlhelper.get_all(sql) if len(data_tuple) != 0: for data in data_tuple: return data else: return None mysqlhelper.close()