Beispiel #1
0
 def register_admin_info(self, password):
     mysqlhelper = MysqlHelper(self.ip, self.port, self.dbname, self.dbuser,
                               self.dbpassword)
     sql = "insert into administrator (username,password) value ('%s','%s')" % (
         self.username, password)
     mysqlhelper.insert(sql)
     mysqlhelper.close()
Beispiel #2
0
 def update_admin_password(self, password):
     mysqlhelper = MysqlHelper(self.ip, self.port, self.dbname, self.dbuser,
                               self.dbpassword)
     sql = "update administrator set password = '******' where username='******'" % (
         password, self.username)
     mysqlhelper.update(sql)
     mysqlhelper.close()
Beispiel #3
0
 def update_mailbox_storage(self, storage):
     mysql_helper = MysqlHelper(self.da_ip, self.port, self.db_name,
                                self.db_user, self.db_password)
     sql = "update mailbox set quota_storage='%s' where username='******';" % (
         storage, self.mail_user)
     mysql_helper.update(sql)
     mysql_helper.close()
Beispiel #4
0
 def insert_mailbox_info(self, new_da_ip, **dict_mailbox_info):
     mysql_helper = MysqlHelper(new_da_ip, self.port, self.db_name,
                                self.db_user, self.db_password)
     ls = [(k, v) for k, v in dict_mailbox_info.items() if v is not None]
     keys = ','.join([i[0] for i in ls])
     values = ','.join(repr(i[1]) for i in ls)
     sql = "insert into mailbox (" + keys + ") values (" + values + ")"
     mysql_helper.insert(sql)
     mysql_helper.close()
Beispiel #5
0
 def update_baseid_nfsid(self, **new_da_id):
     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)
     setsql = ','.join(['%s=%r' % (k, new_da_id[k]) for k in new_da_id])
     sql = "update usersinfo set %s where userid='%s' and domainid=(select domain_id from domain where domain_name='%s')" % (
         setsql, user_id, domain_name)
     mysql_helper.update(sql)
     mysql_helper.close()
Beispiel #6
0
 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
     mysql_helper.close()
Beispiel #7
0
 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()
Beispiel #8
0
 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()
Beispiel #9
0
 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()
Beispiel #10
0
 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
     mysql_helper.close()
Beispiel #11
0
 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
     mysql_helper.close()
Beispiel #12
0
 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
     mysql_helper.close()
Beispiel #13
0
 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()