def LoadMsgText(self, msghead): if (not self.OpenContent(write=False)): return None self.fContent.seek(msghead.pos) msglen = msghead.len if (msglen >= Config.MAX_MSG_SIZE): msglen = Config.MAX_MSG_SIZE - 1 msg = self.fContent.read(msglen) self.CloseContent() return Util.gbkDec(Util.CString(msg))
def BeIgnored(self, userid): if (self.HasPerm(PERM_SYSOP)): return False ignores = User.OwnFile(userid, 'ignores') itemcount = Util.GetRecordCount(ignores, Config.IDLEN + 1) if (itemcount == -1): return False records = Util.GetRecords(ignores, Config.IDLEN + 1, 1, itemcount) for guy in records: if (Util.CString(guy).lower() == self.name.lower()): return True return False
def GetString(login, offset, size): return Util.CString(Utmp.utmpshm.read(size, login * UserInfo.size + offset))
def LoadFavBoards(self): path = User.User.OwnFile(self._userid, "favboard") self._current = -1 fd = open(path, "rb") if fd != None: magic = Util.ReadInt(fd) if magic != 0x8080: self._count = magic index = 0 while index < self._count: bindex = Util.ReadInt(fd) self._favboards[index] = FavBoard(bindex) index = index + 1 else: self._count = Util.ReadInt(fd) index = 0 while index < self._count: flag = Util.ReadInt(fd) title = '' if flag == -1: length = Util.ReadChar(fd) title = Util.gbkDec(Util.CString(fd.read(length))) father = Util.ReadInt(fd) self._favboards[index] = FavBoard(flag, title, father) index = index + 1 fd.close() if self._count <= 0: fd = open(Config.BBS_ROOT + "etc/initial_favboard", "r") if fd == None: self._count = 1 self._favboards[0] = FavBoard(0) else: self._count = 1 self._favboards[0] = FavBoard(0) while True: board = Util.ReadString(fd) if board == '': break bobj = BoardManager.GetBoard(board) if bobj != None: self._favboards[self._count] = FavBoard(bobj.index - 1) fd.close() else: count = self._count index = 0 while index < self._count: fboard = self._favboards[index] if fboard.IsDir(): index = index + 1 continue bindex = fboard._index board = BoardManager.GetBoardByIndex(bindex + 1) user = UserManager.LoadUser(self._userid) if ((bindex >= 0) and (bindex <= BCache.GetBoardCount()) and (user != None) and (board != None) and (board.CheckSeePerm(user))): index = index + 1 continue self.DelFavBoard(index) index = index + 1 if count != self._count: self.SaveFavBoards()
def __get__(self, obj, val): return Util.CString(Field.__get__(self, obj, val))