Exemplo n.º 1
0
        private string insertNew(string key, string board_id, string discussion_id, bool insert_if_not_exist)
        {
            string obj = Warehouse.KeyStoreTable.GetStringProperty(key, EMPTY_ROW_KEY, GroupStore.InsiderGroupName);

            if (obj == null && insert_if_not_exist)
            {
                obj = CryptUtil.GenerateKey();
                Warehouse.KeyStoreTable.SetStringProperty(key, EMPTY_ROW_KEY, GroupStore.InsiderGroupName, obj);

                obj = Warehouse.KeyStoreTable.GetStringProperty(key, EMPTY_ROW_KEY, GroupStore.InsiderGroupName);
            }
            if (obj == null)
            {
                Util.ThrowAttackException("不存在的discussion key。");
            }

            HttpRuntime.Cache.Insert(key, obj, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20));

            return(obj);
        }
Exemplo n.º 2
0
        private static void fillWords(DynamicTableEntity entity, string words, string board_id, string discussion_id)
        {
            string flags   = entity.GetFlags();
            bool   encrypt = SandFlags.Check(flags, SandFlags.MT_AUTHORIZATION, 2);

            if (encrypt)
            {
                entity["abstract"] = new EntityProperty(string.Empty);

                string key   = Warehouse.DiscussionKeyPond.Get(board_id, discussion_id, true);
                string crypt = CryptUtil.Encrypt(words, key);

                entity["words"] = new EntityProperty(crypt);
#if DEBUG
                string plain = CryptUtil.Decrypt(crypt, key);
                if (words != plain)
                {
                    throw new ProgramLogicException();
                }
#endif
            }
            else if (words.Length > ABSTRACT_MAX_LEN)
            {
                int p = words.LastIndexOfAny(Util.WordsSplitCharacters, ABSTRACT_MAX_LEN);
                if (p == -1)
                {
                    p = 0;
                }

                entity["abstract"] = new EntityProperty(words.Substring(0, p));
                entity["words"]    = new EntityProperty(words.Substring(p));
            }
            else
            {
                entity["abstract"] = new EntityProperty(words);
                entity.Properties.Remove("words");
            }
        }