Ejemplo n.º 1
0
        public IHttpActionResult Main()
        {
            try
            {
                var request = new AuthRequest();

                var siteId        = request.GetPostInt("siteId");
                var pageChannelId = request.GetPostInt("pageChannelId");
                if (pageChannelId == 0)
                {
                    pageChannelId = siteId;
                }
                var pageContentId   = request.GetPostInt("pageContentId");
                var pageTemplateId  = request.GetPostInt("pageTemplateId");
                var isPageRefresh   = request.GetPostBool("isPageRefresh");
                var templateContent = TranslateUtils.DecryptStringBySecretKey(request.GetPostString("templateContent"));
                var ajaxDivId       = AttackUtils.FilterSqlAndXss(request.GetPostString("ajaxDivId"));

                var channelId = request.GetPostInt("channelId");
                if (channelId == 0)
                {
                    channelId = pageChannelId;
                }
                var contentId = request.GetPostInt("contentId");
                if (contentId == 0)
                {
                    contentId = pageContentId;
                }

                var pageUrl   = TranslateUtils.DecryptStringBySecretKey(request.GetPostString("pageUrl"));
                var pageIndex = request.GetPostInt("pageNum");
                if (pageIndex > 0)
                {
                    pageIndex--;
                }

                var queryString = PageUtils.GetQueryStringFilterXss(PageUtils.UrlDecode(HttpContext.Current.Request.RawUrl));
                queryString.Remove("siteId");

                return(Ok(new
                {
                    Html = StlDynamic.ParseDynamicContent(siteId, channelId, contentId, pageTemplateId, isPageRefresh, templateContent, pageUrl, pageIndex, ajaxDivId, queryString, request.UserInfo)
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public static DynamicInfo GetDynamicInfo(IAuthenticatedRequest request, UserInfo userInfo)
        {
            var dynamicInfo = TranslateUtils.JsonDeserialize <DynamicInfo>(TranslateUtils.DecryptStringBySecretKey(request.GetPostString("value")));

            if (dynamicInfo.ChannelId == 0)
            {
                dynamicInfo.ChannelId = dynamicInfo.SiteId;
            }
            dynamicInfo.UserInfo    = userInfo;
            dynamicInfo.QueryString =
                PageUtils.GetQueryStringFilterXss(PageUtils.UrlDecode(HttpContext.Current.Request.RawUrl));
            dynamicInfo.QueryString.Remove("siteId");

            dynamicInfo.Page = request.GetPostInt("page");

            return(dynamicInfo);
        }
Ejemplo n.º 3
0
        public static string Decrypt(string inputString)
        {
            if (string.IsNullOrEmpty(inputString))
            {
                return(string.Empty);
            }

            return(TranslateUtils.DecryptStringBySecretKey(inputString, "TgQQk42O"));

            //var encryptor = new DesEncryptor
            //{
            //    InputString = inputString,
            //    DecryptKey = "TgQQk42O"
            //};
            //encryptor.DesDecrypt();
            //return encryptor.OutString;
        }
Ejemplo n.º 4
0
        public void Main(int publishmentSystemId)
        {
            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

            try
            {
                var contentInfo = DataProvider.ResumeContentDao.GetContentInfo(publishmentSystemId, HttpContext.Current.Request.Form);

                DataProvider.ResumeContentDao.Insert(contentInfo);

                string message;

                if (string.IsNullOrEmpty(HttpContext.Current.Request.Form["successTemplateString"]))
                {
                    message = "简历添加成功。";
                }
                else
                {
                    message = TranslateUtils.DecryptStringBySecretKey(HttpContext.Current.Request.Form["successTemplateString"]);
                }

                HttpContext.Current.Response.Write(ResumeTemplate.GetCallbackScript(publishmentSystemInfo, true, message));
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                string message;

                if (string.IsNullOrEmpty(HttpContext.Current.Request.Form["failureTemplateString"]))
                {
                    //message = "简历添加失败," + ex.Message;
                    message = "简历添加失败,程序出错。";
                }
                else
                {
                    message = TranslateUtils.DecryptStringBySecretKey(HttpContext.Current.Request.Form["failureTemplateString"]);
                }

                HttpContext.Current.Response.Write(ResumeTemplate.GetCallbackScript(publishmentSystemInfo, false, message));
                HttpContext.Current.Response.End();
            }
        }
Ejemplo n.º 5
0
        public IHttpActionResult Main()
        {
            try
            {
                var request = new AuthRequest();

                var siteId     = request.GetPostInt("siteId");
                var channelId  = request.GetPostInt("channelId");
                var contentId  = request.GetPostInt("contentId");
                var templateId = request.GetPostInt("templateId");
                var ajaxDivId  = AttackUtils.FilterSqlAndXss(request.GetPostString("ajaxDivId"));
                var pageUrl    = TranslateUtils.DecryptStringBySecretKey(request.GetPostString("pageUrl"));
                var testType   = AttackUtils.FilterSqlAndXss(request.GetPostString("testType"));
                //var testValue = PageUtils.FilterSqlAndXss(request.GetPostString("testValue"));
                //var testOperate = PageUtils.FilterSqlAndXss(request.GetPostString("testOperate"));
                var successTemplate = TranslateUtils.DecryptStringBySecretKey(request.GetPostString("successTemplate"));
                var failureTemplate = TranslateUtils.DecryptStringBySecretKey(request.GetPostString("failureTemplate"));

                var isSuccess = false;
                if (StringUtils.EqualsIgnoreCase(testType, StlIf.TypeIsUserLoggin))
                {
                    isSuccess = request.IsUserLoggin;
                }
                else if (StringUtils.EqualsIgnoreCase(testType, StlIf.TypeIsAdministratorLoggin))
                {
                    isSuccess = request.IsAdminLoggin;
                }
                else if (StringUtils.EqualsIgnoreCase(testType, StlIf.TypeIsUserOrAdministratorLoggin))
                {
                    isSuccess = request.IsUserLoggin || request.IsAdminLoggin;
                }

                return(Ok(new
                {
                    Html = StlDynamic.ParseDynamicContent(siteId, channelId, contentId, templateId, false, isSuccess ? successTemplate : failureTemplate, pageUrl, 0, ajaxDivId, null, request.UserInfo)
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Ejemplo n.º 6
0
        public void Page_Load(object sender, EventArgs e)
        {
            var message    = string.Empty;
            var stackTrace = string.Empty;

            try
            {
                var logId = TranslateUtils.ToInt(Request.QueryString["logId"]);
                if (logId > 0)
                {
                    var pair = DataProvider.ErrorLogDao.GetMessageAndStacktrace(logId);
                    message    = pair.Key;
                    stackTrace = pair.Value;

                    var rollbarTitle = message;
                    if (rollbarTitle == "未将对象引用设置到对象的实例。")
                    {
                        rollbarTitle = StringUtils.Guid();
                    }

                    LtlStackTrace.Text = $@"<script>Rollbar.error(""{StringUtils.ToJsString(rollbarTitle)}"", {{version: ""{StringUtils.ToJsString(SystemManager.Version) + (WebConfigUtils.IsNightlyUpdate ? "-nightly" : string.Empty)}"", stackTrace: ""{StringUtils.ToJsString(stackTrace)}""}});</script>";
                }
                if (string.IsNullOrEmpty(message))
                {
                    message    = TranslateUtils.DecryptStringBySecretKey(Request.QueryString["message"]);
                    stackTrace = TranslateUtils.DecryptStringBySecretKey(Request.QueryString["stackTrace"]);
                }
            }
            catch (Exception ex)
            {
                message    = ex.Message;
                stackTrace = ex.StackTrace;
            }

            LtlMessage.Text = message;
            if (!string.IsNullOrEmpty(stackTrace))
            {
                LtlStackTrace.Text += $@"<!-- 
{stackTrace}
-->";
            }
        }
Ejemplo n.º 7
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _id = AuthRequest.GetQueryInt("id");

            if (IsPostBack)
            {
                return;
            }

            var tokenInfo = DataProvider.AccessTokenDao.GetAccessTokenInfo(_id);

            LtlTitle.Text       = tokenInfo.Title;
            LtlToken.Text       = TranslateUtils.DecryptStringBySecretKey(tokenInfo.Token);
            LtlAddDate.Text     = DateUtils.GetDateAndTimeString(tokenInfo.AddDate);
            LtlUpdatedDate.Text = DateUtils.GetDateAndTimeString(tokenInfo.UpdatedDate);
        }
Ejemplo n.º 8
0
        public void Regenerate_OnClick(object sender, EventArgs e)
        {
            if (!IsPostBack || !IsValid)
            {
                return;
            }

            try
            {
                LtlToken.Text       = TranslateUtils.DecryptStringBySecretKey(DataProvider.AccessTokenDao.Regenerate(_id));
                LtlUpdatedDate.Text = DateUtils.GetDateAndTimeString(DateTime.Now);

                AuthRequest.AddAdminLog("重设API密钥");

                SuccessMessage("API密钥重新设置成功!");
            }
            catch (Exception ex)
            {
                FailMessage(ex, "API密钥重新设置失败!");
            }
        }
Ejemplo n.º 9
0
        public string GetLoadingCategorys(int parentId, string loadingType, string additional)
        {
            var arraylist = new ArrayList();

            var eLoadingType = ECategoryLoadingTypeUtils.GetEnumType(loadingType);

            var categoryIdList      = DataProviderWx.StoreCategoryDao.GetCategoryIdListByParentId(PublishmentSystemId, parentId);
            var nameValueCollection = TranslateUtils.ToNameValueCollection(TranslateUtils.DecryptStringBySecretKey(additional));
            var allCategoryIdList   = new List <int>();

            if (!string.IsNullOrEmpty(nameValueCollection["CategoryIDCollection"]))
            {
                allCategoryIdList = TranslateUtils.StringCollectionToIntList(nameValueCollection["CategoryIDCollection"]);
                nameValueCollection.Remove("CategoryIDCollection");
                foreach (var categotyId in categoryIdList)
                {
                    var categoryInfo = DataProviderWx.StoreCategoryDao.GetCategoryInfo(categotyId);
                    if (categoryInfo.ParentId != 0 || allCategoryIdList.Contains(categotyId))
                    {
                        arraylist.Add(PageStoreCategory.GetCategoryRowHtml(PublishmentSystemId, categoryInfo, eLoadingType, nameValueCollection));
                    }
                }
            }
            else
            {
                foreach (var categotyId in categoryIdList)
                {
                    var categoryInfo = DataProviderWx.StoreCategoryDao.GetCategoryInfo(categotyId);
                    arraylist.Add(PageStoreCategory.GetCategoryRowHtml(PublishmentSystemId, categoryInfo, eLoadingType, nameValueCollection));
                }
            }

            var builder = new StringBuilder();

            foreach (string html in arraylist)
            {
                builder.Append(html);
            }
            return(builder.ToString());
        }
Ejemplo n.º 10
0
        public string GetLoadingDepartments(int parentId, string loadingType, string additional)
        {
            var arraylist = new ArrayList();

            var eLoadingType = EDepartmentLoadingTypeUtils.GetEnumType(loadingType);

            var departmentIdList    = DataProvider.DepartmentDao.GetIdListByParentId(parentId);
            var nameValueCollection = TranslateUtils.ToNameValueCollection(TranslateUtils.DecryptStringBySecretKey(additional));

            if (!string.IsNullOrEmpty(nameValueCollection["DepartmentIDCollection"]))
            {
                var allDepartmentIdArrayList = TranslateUtils.StringCollectionToIntList(nameValueCollection["DepartmentIDCollection"]);
                nameValueCollection.Remove("DepartmentIDCollection");
                foreach (var departmentId in departmentIdList)
                {
                    var departmentInfo = DepartmentManager.GetDepartmentInfo(departmentId);
                    if (departmentInfo.ParentId != 0 || allDepartmentIdArrayList.Contains(departmentId))
                    {
                        arraylist.Add(PageAdminDepartment.GetDepartmentRowHtml(departmentInfo, eLoadingType, nameValueCollection));
                    }
                }
            }
            else
            {
                foreach (var departmentId in departmentIdList)
                {
                    var departmentInfo = DepartmentManager.GetDepartmentInfo(departmentId);
                    arraylist.Add(PageAdminDepartment.GetDepartmentRowHtml(departmentInfo, eLoadingType, nameValueCollection));
                }
            }

            var builder = new StringBuilder();

            foreach (string html in arraylist)
            {
                builder.Append(html);
            }
            return(builder.ToString());
        }
        public IHttpActionResult Regenerate(int id)
        {
            try
            {
                var request = new AuthenticatedRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.SettingsPermissions.Admin))
                {
                    return(Unauthorized());
                }

                var accessToken = TranslateUtils.DecryptStringBySecretKey(DataProvider.AccessTokenDao.Regenerate(id));

                return(Ok(new
                {
                    Value = accessToken
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Ejemplo n.º 12
0
        public string GetLoadingChannels(int siteId, int parentId, string loadingType, string additional, Request request)
        {
            var list = new List <string>();

            var eLoadingType = ELoadingTypeUtils.GetEnumType(loadingType);

            var channelIdList = DataProvider.ChannelDao.GetIdListByParentId(siteId, parentId);

            var siteInfo = SiteManager.GetSiteInfo(siteId);

            var nameValueCollection = TranslateUtils.ToNameValueCollection(TranslateUtils.DecryptStringBySecretKey(additional));

            foreach (var channelId in channelIdList)
            {
                var enabled = AdminUtility.IsOwningChannelId(request.AdminName, channelId);
                if (!enabled)
                {
                    if (!AdminUtility.IsHasChildOwningChannelId(request.AdminName, channelId))
                    {
                        continue;
                    }
                }
                var nodeInfo = ChannelManager.GetChannelInfo(siteId, channelId);

                list.Add(ChannelLoading.GetChannelRowHtml(siteInfo, nodeInfo, enabled, eLoadingType, nameValueCollection, request.AdminName));
            }

            //arraylist.Reverse();

            var builder = new StringBuilder();

            foreach (var html in list)
            {
                builder.Append(html);
            }
            return(builder.ToString());
        }
Ejemplo n.º 13
0
        public string GetLoadingChannels(int publishmentSystemId, int parentId, string loadingType, string additional, RequestBody body)
        {
            var arraylist = new ArrayList();

            var eLoadingType = ELoadingTypeUtils.GetEnumType(loadingType);

            var nodeIdList = DataProvider.NodeDao.GetNodeIdListByParentId(publishmentSystemId, parentId);

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

            var nameValueCollection = TranslateUtils.ToNameValueCollection(TranslateUtils.DecryptStringBySecretKey(additional));

            foreach (int nodeId in nodeIdList)
            {
                var enabled = AdminUtility.IsOwningNodeId(body.AdministratorName, nodeId);
                if (!enabled)
                {
                    if (!AdminUtility.IsHasChildOwningNodeId(body.AdministratorName, nodeId))
                    {
                        continue;
                    }
                }
                var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, nodeId);

                arraylist.Add(ChannelLoading.GetChannelRowHtml(publishmentSystemInfo, nodeInfo, enabled, eLoadingType, nameValueCollection, body.AdministratorName));
            }

            //arraylist.Reverse();

            var builder = new StringBuilder();

            foreach (string html in arraylist)
            {
                builder.Append(html);
            }
            return(builder.ToString());
        }
        public IHttpActionResult GetAccessToken(int id)
        {
            try
            {
                var request = new AuthRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissions.HasAdministratorPermissions(ConfigManager.SettingsPermissions.Admin))
                {
                    return(Unauthorized());
                }

                var tokenInfo   = DataProvider.AccessTokenDao.GetAccessTokenInfo(id);
                var accessToken = TranslateUtils.DecryptStringBySecretKey(tokenInfo.Token);

                return(Ok(new
                {
                    Value = accessToken
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Ejemplo n.º 15
0
        public IHttpActionResult Main()
        {
            try
            {
                var body = new RequestBody();
                var form = HttpContext.Current.Request.Form;

                var isAllSites          = body.GetPostBool(StlSearch.AttributeIsAllSites.ToLower());
                var siteName            = PageUtils.FilterSqlAndXss(body.GetPostString(StlSearch.AttributeSiteName.ToLower()));
                var siteDir             = PageUtils.FilterSqlAndXss(body.GetPostString(StlSearch.AttributeSiteDir.ToLower()));
                var siteIds             = PageUtils.FilterSqlAndXss(body.GetPostString(StlSearch.AttributeSiteIds.ToLower()));
                var channelIndex        = PageUtils.FilterSqlAndXss(body.GetPostString(StlSearch.AttributeChannelIndex.ToLower()));
                var channelName         = PageUtils.FilterSqlAndXss(body.GetPostString(StlSearch.AttributeChannelName.ToLower()));
                var channelIds          = PageUtils.FilterSqlAndXss(body.GetPostString(StlSearch.AttributeChannelIds.ToLower()));
                var type                = PageUtils.FilterSqlAndXss(body.GetPostString(StlSearch.AttributeType.ToLower()));
                var word                = PageUtils.FilterSql(body.GetPostString(StlSearch.AttributeWord.ToLower()));
                var dateAttribute       = PageUtils.FilterSqlAndXss(body.GetPostString(StlSearch.AttributeDateAttribute.ToLower()));
                var dateFrom            = PageUtils.FilterSqlAndXss(body.GetPostString(StlSearch.AttributeDateFrom.ToLower()));
                var dateTo              = PageUtils.FilterSqlAndXss(body.GetPostString(StlSearch.AttributeDateTo.ToLower()));
                var since               = PageUtils.FilterSqlAndXss(body.GetPostString(StlSearch.AttributeSince.ToLower()));
                var pageNum             = body.GetPostInt(StlSearch.AttributePageNum.ToLower());
                var isHighlight         = body.GetPostBool(StlSearch.AttributeIsHighlight.ToLower());
                var isDefaultDisplay    = body.GetPostBool(StlSearch.AttributeIsDefaultDisplay.ToLower());
                var publishmentSystemId = body.GetPostInt("publishmentsystemid");
                var ajaxDivId           = PageUtils.FilterSqlAndXss(body.GetPostString("ajaxdivid"));
                var template            = TranslateUtils.DecryptStringBySecretKey(body.GetPostString("template"));
                var pageIndex           = body.GetPostInt("page", 1) - 1;

                var templateInfo          = new TemplateInfo(0, publishmentSystemId, string.Empty, ETemplateType.FileTemplate, string.Empty, string.Empty, string.Empty, ECharset.utf_8, false);
                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                var pageInfo       = new PageInfo(publishmentSystemId, 0, publishmentSystemInfo, templateInfo, body.UserInfo);
                var contextInfo    = new ContextInfo(pageInfo);
                var contentBuilder = new StringBuilder(StlRequestEntities.ParseRequestEntities(form, template));

                var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString());

                if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList))
                {
                    var stlElement             = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlLabelList);
                    var stlPageContentsElement = stlElement;
                    var stlPageContentsElementReplaceString = stlElement;

                    bool isDefaultCondition;
                    var  whereString = DataProvider.ContentDao.GetWhereStringByStlSearch(isAllSites, siteName, siteDir, siteIds, channelIndex, channelName, channelIds, type, word, dateAttribute, dateFrom, dateTo, since, publishmentSystemId, ActionsSearch.ExlcudeAttributeNames, form, out isDefaultCondition);

                    //没搜索条件时不显示搜索结果
                    if (isDefaultCondition && !isDefaultDisplay)
                    {
                        return(NotFound());
                    }

                    var stlPageContents = new StlPageContents(stlPageContentsElement, pageInfo, contextInfo, pageNum, publishmentSystemInfo.AuxiliaryTableForContent, whereString);

                    int totalNum;
                    var pageCount = stlPageContents.GetPageCount(out totalNum);

                    if (totalNum == 0)
                    {
                        return(NotFound());
                    }

                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex != pageIndex)
                        {
                            continue;
                        }

                        var pageHtml     = stlPageContents.Parse(totalNum, currentPageIndex, pageCount, false);
                        var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlPageContentsElementReplaceString, pageHtml));

                        StlParserManager.ReplacePageElementsInSearchPage(pagedBuilder, pageInfo, stlLabelList, ajaxDivId, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum);

                        if (isHighlight && !string.IsNullOrEmpty(word))
                        {
                            var pagedContents = pagedBuilder.ToString();
                            pagedBuilder = new StringBuilder();
                            pagedBuilder.Append(RegexUtils.Replace(
                                                    $"({word.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", pagedContents,
                                                    $"<span style='color:#cc0000'>{word}</span>"));
                        }

                        StlUtility.ParseStl(publishmentSystemInfo, pageInfo, contextInfo, pagedBuilder, string.Empty, false);
                        return(Ok(pagedBuilder.ToString()));
                    }
                }

                StlUtility.ParseStl(publishmentSystemInfo, pageInfo, contextInfo, contentBuilder, string.Empty, false);
                return(Ok(contentBuilder.ToString()));
            }
            catch (Exception ex)
            {
                //return InternalServerError(ex);
                return(InternalServerError(new Exception("程序错误")));
            }
        }
Ejemplo n.º 16
0
        public void Main()
        {
            var isSuccess = false;

            try
            {
                var request = new AuthRequest();

                if (!string.IsNullOrEmpty(request.GetQueryString("siteId")) && !string.IsNullOrEmpty(request.GetQueryString("fileUrl")) && string.IsNullOrEmpty(request.GetQueryString("contentId")))
                {
                    var siteId  = request.GetQueryInt("siteId");
                    var fileUrl = TranslateUtils.DecryptStringBySecretKey(request.GetQueryString("fileUrl"));

                    if (PageUtils.IsProtocolUrl(fileUrl))
                    {
                        isSuccess = true;
                        PageUtils.Redirect(fileUrl);
                    }
                    else
                    {
                        var siteInfo = SiteManager.GetSiteInfo(siteId);
                        var filePath = PathUtility.MapPath(siteInfo, fileUrl);
                        var fileType = EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(filePath));
                        if (EFileSystemTypeUtils.IsDownload(fileType))
                        {
                            if (FileUtils.IsFileExists(filePath))
                            {
                                isSuccess = true;
                                PageUtils.Download(HttpContext.Current.Response, filePath);
                            }
                        }
                        else
                        {
                            isSuccess = true;
                            PageUtils.Redirect(PageUtility.ParseNavigationUrl(siteInfo, fileUrl, false));
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(request.GetQueryString("filePath")))
                {
                    var filePath = TranslateUtils.DecryptStringBySecretKey(request.GetQueryString("filePath"));
                    var fileType = EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(filePath));
                    if (EFileSystemTypeUtils.IsDownload(fileType))
                    {
                        if (FileUtils.IsFileExists(filePath))
                        {
                            isSuccess = true;
                            PageUtils.Download(HttpContext.Current.Response, filePath);
                        }
                    }
                    else
                    {
                        isSuccess = true;
                        var fileUrl = PageUtils.GetRootUrlByPhysicalPath(filePath);
                        PageUtils.Redirect(PageUtils.ParseNavigationUrl(fileUrl));
                    }
                }
                else if (!string.IsNullOrEmpty(request.GetQueryString("siteId")) && !string.IsNullOrEmpty(request.GetQueryString("channelId")) && !string.IsNullOrEmpty(request.GetQueryString("contentId")) && !string.IsNullOrEmpty(request.GetQueryString("fileUrl")))
                {
                    var siteId      = request.GetQueryInt("siteId");
                    var channelId   = request.GetQueryInt("channelId");
                    var contentId   = request.GetQueryInt("contentId");
                    var fileUrl     = TranslateUtils.DecryptStringBySecretKey(request.GetQueryString("fileUrl"));
                    var siteInfo    = SiteManager.GetSiteInfo(siteId);
                    var nodeInfo    = ChannelManager.GetChannelInfo(siteId, channelId);
                    var tableName   = ChannelManager.GetTableName(siteInfo, nodeInfo);
                    var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);

                    if (!string.IsNullOrEmpty(contentInfo?.GetString(BackgroundContentAttribute.FileUrl)))
                    {
                        //string fileUrl = contentInfo.GetString(BackgroundContentAttribute.FileUrl);
                        if (siteInfo.Additional.IsCountDownload)
                        {
                            CountManager.AddCount(tableName, contentId.ToString(), ECountType.Download);
                        }

                        if (PageUtils.IsProtocolUrl(fileUrl))
                        {
                            isSuccess = true;
                            PageUtils.Redirect(fileUrl);
                        }
                        else
                        {
                            var filePath = PathUtility.MapPath(siteInfo, fileUrl, true);
                            var fileType = EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(filePath));
                            if (EFileSystemTypeUtils.IsDownload(fileType))
                            {
                                if (FileUtils.IsFileExists(filePath))
                                {
                                    isSuccess = true;
                                    PageUtils.Download(HttpContext.Current.Response, filePath);
                                }
                            }
                            else
                            {
                                isSuccess = true;
                                PageUtils.Redirect(PageUtility.ParseNavigationUrl(siteInfo, fileUrl, false));
                            }
                        }
                    }
                }
            }
            catch
            {
                // ignored
            }
            if (!isSuccess)
            {
                HttpContext.Current.Response.Write("下载失败,不存在此文件!");
            }
        }
        public void Main()
        {
            try
            {
                var request = new AuthenticatedRequest();

                if (!string.IsNullOrEmpty(request.GetQueryString("siteId")) && !string.IsNullOrEmpty(request.GetQueryString("fileUrl")) && string.IsNullOrEmpty(request.GetQueryString("contentId")))
                {
                    var siteId  = request.GetQueryInt("siteId");
                    var fileUrl = TranslateUtils.DecryptStringBySecretKey(request.GetQueryString("fileUrl"));

                    if (PageUtils.IsProtocolUrl(fileUrl))
                    {
                        PageUtils.Redirect(fileUrl);
                        return;
                    }

                    var siteInfo = SiteManager.GetSiteInfo(siteId);
                    var filePath = PathUtility.MapPath(siteInfo, fileUrl);
                    var fileType = EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(filePath));
                    if (EFileSystemTypeUtils.IsDownload(fileType))
                    {
                        if (FileUtils.IsFileExists(filePath))
                        {
                            PageUtils.Download(HttpContext.Current.Response, filePath);
                            return;
                        }
                    }
                    else
                    {
                        PageUtils.Redirect(PageUtility.ParseNavigationUrl(siteInfo, fileUrl, false));
                        return;
                    }
                }
                else if (!string.IsNullOrEmpty(request.GetQueryString("filePath")))
                {
                    var filePath = TranslateUtils.DecryptStringBySecretKey(request.GetQueryString("filePath"));
                    var fileType = EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(filePath));
                    if (EFileSystemTypeUtils.IsDownload(fileType))
                    {
                        if (FileUtils.IsFileExists(filePath))
                        {
                            PageUtils.Download(HttpContext.Current.Response, filePath);
                            return;
                        }
                    }
                    else
                    {
                        var fileUrl = PageUtils.GetRootUrlByPhysicalPath(filePath);
                        PageUtils.Redirect(PageUtils.ParseNavigationUrl(fileUrl));
                        return;
                    }
                }
                else if (!string.IsNullOrEmpty(request.GetQueryString("siteId")) && !string.IsNullOrEmpty(request.GetQueryString("channelId")) && !string.IsNullOrEmpty(request.GetQueryString("contentId")) && !string.IsNullOrEmpty(request.GetQueryString("fileUrl")))
                {
                    var siteId      = request.GetQueryInt("siteId");
                    var channelId   = request.GetQueryInt("channelId");
                    var contentId   = request.GetQueryInt("contentId");
                    var fileUrl     = TranslateUtils.DecryptStringBySecretKey(request.GetQueryString("fileUrl"));
                    var siteInfo    = SiteManager.GetSiteInfo(siteId);
                    var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                    var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId);

                    DataProvider.ContentDao.AddDownloads(siteId, ChannelManager.GetTableName(siteInfo, channelInfo), channelId, contentId);

                    if (!string.IsNullOrEmpty(contentInfo?.GetString(BackgroundContentAttribute.FileUrl)))
                    {
                        if (PageUtils.IsProtocolUrl(fileUrl))
                        {
                            PageUtils.Redirect(fileUrl);
                            return;
                        }

                        var filePath = PathUtility.MapPath(siteInfo, fileUrl, true);
                        var fileType = EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(filePath));
                        if (EFileSystemTypeUtils.IsDownload(fileType))
                        {
                            if (FileUtils.IsFileExists(filePath))
                            {
                                PageUtils.Download(HttpContext.Current.Response, filePath);
                                return;
                            }
                        }
                        else
                        {
                            PageUtils.Redirect(PageUtility.ParseNavigationUrl(siteInfo, fileUrl, false));
                            return;
                        }
                    }
                }
            }
            catch
            {
                // ignored
            }

            HttpContext.Current.Response.Write("下载失败,不存在此文件!");
        }
Ejemplo n.º 18
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            if (AuthRequest.IsQueryExists("CreateChannelsOneByOne") && AuthRequest.IsQueryExists("ChannelIDCollection"))
            {
                foreach (var channelId in TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("ChannelIDCollection")))
                {
                    CreateManager.CreateChannel(SiteId, channelId);
                }

                LayerUtils.CloseAndOpenPageCreateStatus(Page);
                //PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将栏目放入生成队列"));
            }
            else if (AuthRequest.IsQueryExists("CreateContentsOneByOne") && AuthRequest.IsQueryExists("channelId") &&
                     AuthRequest.IsQueryExists("contentIdCollection"))
            {
                foreach (var contentId in TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("contentIdCollection")))
                {
                    CreateManager.CreateContent(SiteId, AuthRequest.GetQueryInt("channelId"),
                                                contentId);
                }

                LayerUtils.CloseAndOpenPageCreateStatus(Page);
                //PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将内容放入生成队列"));
            }
            else if (AuthRequest.IsQueryExists("CreateByTemplate") && AuthRequest.IsQueryExists("templateID"))
            {
                CreateManager.CreateFile(SiteId, AuthRequest.GetQueryInt("templateID"));

                LayerUtils.CloseAndOpenPageCreateStatus(Page);
                //PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将文件放入生成队列"));
            }
            else if (AuthRequest.IsQueryExists("CreateByIDsCollection") && AuthRequest.IsQueryExists("IDsCollection"))
            {
                foreach (var channelIdContentId in
                         TranslateUtils.StringCollectionToStringCollection(AuthRequest.GetQueryString("IDsCollection")))
                {
                    var pair = channelIdContentId.Split('_');
                    CreateManager.CreateContent(SiteId, TranslateUtils.ToInt(pair[0]),
                                                TranslateUtils.ToInt(pair[1]));
                }

                LayerUtils.CloseAndOpenPageCreateStatus(Page);
                //PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将文件放入生成队列"));
            }
            //---------------------------------------------------------------------------------------//
            else if (AuthRequest.IsQueryExists("SiteTemplateDownload"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var downloadUrl   = TranslateUtils.DecryptStringBySecretKey(AuthRequest.GetQueryString("DownloadUrl"));
                var directoryName = PathUtils.GetFileNameWithoutExtension(downloadUrl);

                var parameters = AjaxOtherService.GetSiteTemplateDownloadParameters(downloadUrl, directoryName, userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateDownloadUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            else if (AuthRequest.IsQueryExists("SiteTemplateZip"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetSiteTemplateZipParameters(AuthRequest.GetQueryString("DirectoryName"), userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateZipUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            else if (AuthRequest.IsQueryExists("SiteTemplateUnZip"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetSiteTemplateUnZipParameters(AuthRequest.GetQueryString("FileName"), userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateUnZipUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            //---------------------------------------------------------------------------------------//
            else if (AuthRequest.IsQueryExists("PluginDownload"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetPluginDownloadParameters(AuthRequest.GetQueryString("DownloadUrl"), userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetPluginDownloadUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
        }
Ejemplo n.º 19
0
 public string Decrypt(string inputString)
 {
     return(TranslateUtils.DecryptStringBySecretKey(inputString));
 }
        public void Main()
        {
            var builder = new StringBuilder();

            try
            {
                var form = HttpContext.Current.Request.Form;
                var publishmentSystemId = TranslateUtils.ToInt(form["publishmentSystemID"]);
                var parentId            = TranslateUtils.ToInt(form["parentID"]);
                var target              = form["target"];
                var isShowTreeLine      = TranslateUtils.ToBool(form["isShowTreeLine"]);
                var isShowContentNum    = TranslateUtils.ToBool(form["isShowContentNum"]);
                var currentFormatString = form["currentFormatString"];
                var topNodeId           = TranslateUtils.ToInt(form["topNodeID"]);
                var topParentsCount     = TranslateUtils.ToInt(form["topParentsCount"]);
                var currentNodeId       = TranslateUtils.ToInt(form["currentNodeID"]);

                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                var nodeIdList            = DataProvider.NodeDao.GetNodeIdListByParentId(publishmentSystemId, parentId);

                foreach (int nodeId in nodeIdList)
                {
                    var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, nodeId);

                    builder.Append(StlTree.GetChannelRowHtml(publishmentSystemInfo, nodeInfo, target, isShowTreeLine, isShowContentNum, TranslateUtils.DecryptStringBySecretKey(currentFormatString), topNodeId, topParentsCount, currentNodeId));
                }
            }
            catch
            {
                // ignored
            }

            HttpContext.Current.Response.Write(builder);
            HttpContext.Current.Response.End();
        }
Ejemplo n.º 21
0
        public void Page_Load(object sender, EventArgs e)
        {
            var    type      = Request["type"];
            var    retval    = new NameValueCollection();
            string retString = null;
            var    request   = new Request();

            if (!request.IsAdminLoggin)
            {
                return;
            }

            if (type == TypeGetCountArray)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                retval = GetCountArray(userKeyPrefix);
            }
            else if (type == TypeSiteTemplateDownload)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                var downloadUrl   = TranslateUtils.DecryptStringBySecretKey(Request["downloadUrl"]);
                var directoryName = Request["directoryName"];
                retval = SiteTemplateDownload(downloadUrl, directoryName, userKeyPrefix);
            }
            else if (type == TypeSiteTemplateZip)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                var directoryName = Request["directoryName"];
                retval = SiteTemplateZip(directoryName, userKeyPrefix);
            }
            else if (type == TypeSiteTemplateUnZip)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                var fileName      = Request["fileName"];
                retval = SiteTemplateUnZip(fileName, userKeyPrefix);
            }
            else if (type == TypeGetLoadingChannels)
            {
                var siteId      = TranslateUtils.ToInt(Request["siteID"]);
                var parentId    = TranslateUtils.ToInt(Request["parentID"]);
                var loadingType = Request["loadingType"];
                var additional  = Request["additional"];
                retString = GetLoadingChannels(siteId, parentId, loadingType, additional, request);
            }
            else if (type == TypePluginDownload)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                var downloadUrl   = TranslateUtils.DecryptStringBySecretKey(Request["downloadUrl"]);
                retval = PluginDownload(downloadUrl, userKeyPrefix);
            }
            //else if (type == "GetLoadingGovPublicCategories")
            //{
            //    string classCode = base.Request["classCode"];
            //    int siteID = TranslateUtils.ToInt(base.Request["siteID"]);
            //    int parentID = TranslateUtils.ToInt(base.Request["parentID"]);
            //    string loadingType = base.Request["loadingType"];
            //    string additional = base.Request["additional"];
            //    retString = GetLoadingGovPublicCategories(classCode, siteID, parentID, loadingType, additional);
            //}
            //else if (type == "GetLoadingTemplates")
            //{
            //    int siteID = TranslateUtils.ToInt(base.Request["siteID"]);
            //    string templateType = base.Request["templateType"];
            //    retString = GetLoadingTemplates(siteID, templateType);
            //}
            //else if (type == "StlTemplate")
            //{
            //    int siteID = TranslateUtils.ToInt(base.Request["siteID"]);
            //    int templateID = TranslateUtils.ToInt(base.Request["templateID"]);
            //    string includeUrl = base.Request["includeUrl"];
            //    string operation = base.Request["operation"];
            //    retval = TemplateDesignOperation.Operate(siteID, templateID, includeUrl, operation, base.Request.Form);
            //}

            if (retString != null)
            {
                Page.Response.Write(retString);
                Page.Response.End();
            }
            else
            {
                var jsonString = TranslateUtils.NameValueCollectionToJsonString(retval);
                Page.Response.Write(jsonString);
                Page.Response.End();
            }
        }
Ejemplo n.º 22
0
 public string GetRedirectUrl()
 {
     return(TranslateUtils.DecryptStringBySecretKey(AuthRequest.GetQueryString("redirectUrl")));
 }
Ejemplo n.º 23
0
 private string Decrypt(string inputString)
 {
     return(TranslateUtils.DecryptStringBySecretKey(inputString, "TgQQk42O"));
 }
Ejemplo n.º 24
0
        public void Main(int publishmentSystemId)
        {
            var queryString = HttpContext.Current.Request.QueryString;

            var updaterId       = int.Parse(queryString["updaterId"]);
            var relatedIdentity = int.Parse(queryString["relatedIdentity"]);
            var diggType        = EDiggTypeUtils.GetEnumType(queryString["diggType"]);
            var goodText        = TranslateUtils.DecryptStringBySecretKey(queryString["goodText"]);
            var badText         = TranslateUtils.DecryptStringBySecretKey(queryString["badText"]);
            var theme           = queryString["theme"];
            var isDigg          = TranslateUtils.ToBool(queryString["isDigg"]);
            var isGood          = TranslateUtils.ToBool(queryString["isGood"]);

            if (isDigg)
            {
                BaiRongDataProvider.DiggDao.AddCount(publishmentSystemId, relatedIdentity, isGood);
            }

            var counts  = BaiRongDataProvider.DiggDao.GetCount(publishmentSystemId, relatedIdentity);
            var goodNum = counts[0];
            var badNum  = counts[1];

            var goodDisplay = diggType != EDiggType.Bad ? "" : "display: none";
            var badDisplay  = diggType != EDiggType.Good ? "" : "display: none";

            var clickStringOfGood = $"stlDiggSet_{updaterId}(true);return false;";
            var clickStringOfBad  = $"stlDiggSet_{updaterId}(false);return false;";

            decimal goodPercentage;
            decimal badPercentage;

            if (goodNum == 0 && badNum == 0)
            {
                goodPercentage = 0;
                badPercentage  = 0;
            }
            else if (goodNum > 0 && badNum == 0)
            {
                goodPercentage = 100;
                badPercentage  = 0;
            }
            else if (goodNum == 0 && badNum > 0)
            {
                goodPercentage = 0;
                badPercentage  = 100;
            }
            else
            {
                goodPercentage = Math.Round((Convert.ToDecimal(goodNum) / Convert.ToDecimal(goodNum + badNum)) * Convert.ToDecimal(100));
                badPercentage  = 100 - goodPercentage;
            }

            var retval = string.Empty;

            if (theme == "style1")
            {
                retval = string.Format($@"
<div class=""newdigg"" id=""newdigg"">
	<div class=""diggbox digg_good"" onmousemove=""this.style.backgroundPosition='left bottom';"" onmouseout=""this.style.backgroundPosition='left top';"" onclick=""{clickStringOfGood}"" style=""display:{goodDisplay}"">
        <div class=""digg_act"">{goodText}</div>
		<div class=""digg_num"">({goodNum})</div>
		<div class=""digg_percent"">
			<div class=""digg_percent_bar""><span style=""width:{goodPercentage}%""></span></div>
			<div class=""digg_percent_num"">{goodPercentage}%</div>
		</div>
	</div>
    <div class=""diggbox digg_bad"" onmousemove=""this.style.backgroundPosition='right bottom';"" onmouseout=""this.style.backgroundPosition='right top';"" onclick=""{clickStringOfBad}"" style=""{badDisplay}"">
		<div class=""digg_act"">{badText}</div>
		<div class=""digg_num"">({badNum})</div>
		<div class=""digg_percent"">
			<div class=""digg_percent_bar""><span style=""width:{badPercentage}%""></span></div>
			<div class=""digg_percent_num"">{badPercentage}%</div>
		</div>
	</div>
</div>");
            }
            else if (theme == "style2")
            {
                retval = string.Format($@"
<table border=""0"" cellpadding=""0"" cellspacing=""8"" class=""newdigg"">
  <tr>
    <td style=""{goodDisplay}"">
      <table border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"" class=""digg"">
        <tr>
          <td class=""diggnum"" id=""diggnum"">
            <strong>{goodNum}</strong>
          </td>
        </tr>
        <tr>
          <td class=""diggit"">
            <a href=""javascript:;"" onclick=""{clickStringOfGood}"">{goodText}</a>
          </td>
        </tr>
      </table>
    </td>
    <td style=""{badDisplay}"">
      <table border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"" class=""digg"">
        <tr>
          <td class=""diggnum"" id=""diggnum"">
            <strong>{badNum}</strong>
          </td>
        </tr>
        <tr>
          <td class=""diggit"">
            <a href=""javascript:;"" onclick=""{clickStringOfBad}"">{badText}</a>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
");
            }
            else if (theme == "style3")
            {
                retval = string.Format($@"
<table>
    <tr>
        <td align=""center"" style=""{goodDisplay}"">
            <a class=""diggLink"" href=""javascript:;"" onclick=""{clickStringOfGood}"">{goodText}</a>
            <span class=""diggNum"">{goodNum}票</span>
        </td>
        <td align=""center"" style=""{badDisplay}"">
            <a class=""diggLink"" href=""javascript:;"" onclick=""{clickStringOfBad}"">{badText}</a>
            <span class=""diggNum"">{badNum}票</span>
        </td>
    </tr>
</table>
");
            }
            else if (theme == "style4")
            {
                retval = string.Format($@"
<div>
	<div class=""diggArea"" style=""{goodDisplay}"">
        <div class=""diggNum"">{goodNum}</div>
        <div class=""diggLink""><a href=""javascript:;"" onclick=""{clickStringOfGood}"">{goodText}</a></div>
    </div>
    <div class=""diggArea"" style=""{badDisplay}"">
        <div class=""diggNum"">{badNum}</div>
        <div class=""diggLink""><a href=""javascript:;"" onclick=""{clickStringOfBad}"">{badText}</a></div>
    </div>
</div>
");
            }

            HttpContext.Current.Response.Write(retval);
            HttpContext.Current.Response.End();
        }
Ejemplo n.º 25
0
        public IHttpActionResult Main()
        {
            try
            {
                var body = new RequestBody();
                var form = HttpContext.Current.Request.Form;

                var publishmentSystemId   = body.GetPostInt("publishmentSystemId");
                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                var ajaxDivId             = PageUtils.FilterSqlAndXss(body.GetPostString("ajaxDivId"));
                var pageNum          = body.GetPostInt("pageNum");
                var isHighlight      = body.GetPostBool("isHighlight");
                var isRedirectSingle = body.GetPostBool("isRedirectSingle");
                var isDefaultDisplay = body.GetPostBool("isDefaultDisplay");
                var dateAttribute    = PageUtils.FilterSqlAndXss(body.GetPostString("dateAttribute"));
                if (string.IsNullOrEmpty(dateAttribute))
                {
                    dateAttribute = ContentAttribute.AddDate;
                }
                var pageIndex = body.GetPostInt("page", 1) - 1;

                var template = TranslateUtils.DecryptStringBySecretKey(body.GetPostString("template"));
                template = StlRequestEntities.ParseRequestEntities(form, template);
                var word           = PageUtils.FilterSql(body.GetPostString("word"));
                var channelId      = body.GetPostString("channelID");
                var dateFrom       = PageUtils.FilterSqlAndXss(body.GetPostString("dateFrom"));
                var dateTo         = PageUtils.FilterSqlAndXss(body.GetPostString("dateTo"));
                var date           = PageUtils.FilterSqlAndXss(body.GetPostString("date"));
                var typeCollection = TranslateUtils.StringCollectionToStringCollection(PageUtils.UrlDecode(PageUtils.FilterSqlAndXss(body.GetPostString("type"))));

                var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, TranslateUtils.ToInt(channelId, publishmentSystemId));
                if (nodeInfo == null)
                {
                    nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, publishmentSystemId);
                }
                var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);

                var excludeAttributes = "ajaxdivid,pagenum,pageindex,iscrosssite,ishighlight,isredirectsingle,isdefaultdisplay,charset,template,word,click,channelid,datefrom,dateto,date,type,dateattribute";

                var templateInfo = new TemplateInfo(0, publishmentSystemId, string.Empty, ETemplateType.FileTemplate, string.Empty, string.Empty, string.Empty, ECharsetUtils.GetEnumType(publishmentSystemInfo.Additional.Charset), false);

                var pageInfo    = new PageInfo(nodeInfo.NodeId, 0, publishmentSystemInfo, templateInfo, body.UserInfo);
                var contextInfo = new ContextInfo(pageInfo);

                var contentBuilder = new StringBuilder(template);

                var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString());

                if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList))
                {
                    var stlElement             = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlLabelList);
                    var stlPageContentsElement = stlElement;
                    var stlPageContentsElementReplaceString = stlElement;

                    var whereString = DataProvider.ContentDao.GetWhereStringBySearchOutput(publishmentSystemInfo, nodeInfo.NodeId, tableStyle, word, typeCollection, channelId, dateFrom, dateTo, date, dateAttribute, excludeAttributes, form);

                    //没搜索条件时不显示搜索结果
                    if (string.IsNullOrEmpty(whereString) && !isDefaultDisplay)
                    {
                        return(Ok(string.Empty));
                    }

                    var stlPageContents = new StlPageContents(stlPageContentsElement, pageInfo, contextInfo, pageNum, whereString);

                    int totalNum;
                    var pageCount = stlPageContents.GetPageCount(out totalNum);

                    if (totalNum == 0)
                    {
                        return(NotFound());
                    }
                    var isRedirect = false;
                    if (isRedirectSingle && totalNum == 1)
                    {
                        var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, stlPageContents.SqlString);
                        if (contentInfo != null)
                        {
                            isRedirect     = true;
                            contentBuilder = new StringBuilder($@"
<script>
location.href = '{PageUtility.GetContentUrl(publishmentSystemInfo, contentInfo)}';
</script>
");
                        }
                    }
                    if (!isRedirect)
                    {
                        for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                        {
                            if (currentPageIndex == pageIndex)
                            {
                                var pageHtml     = stlPageContents.Parse(totalNum, currentPageIndex, pageCount, false);
                                var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlPageContentsElementReplaceString, pageHtml));

                                StlParserManager.ReplacePageElementsInSearchPage(pagedBuilder, pageInfo, stlLabelList, ajaxDivId, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum);

                                if (isHighlight && !string.IsNullOrEmpty(word))
                                {
                                    var pagedContents = pagedBuilder.ToString();
                                    pagedBuilder = new StringBuilder();
                                    pagedBuilder.Append(RegexUtils.Replace(
                                                            $"({word.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", pagedContents,
                                                            $"<span style='color:#cc0000'>{word}</span>"));
                                }

                                StlUtility.ParseStl(publishmentSystemInfo, pageInfo, contextInfo, pagedBuilder, string.Empty, false);
                                return(Ok(pagedBuilder.ToString()));
                            }
                        }
                    }
                }
                else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlLabelList))
                {
                    var siteId     = TranslateUtils.ToInt(body.GetPostString("siteID"), 0);
                    var stlElement = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlLabelList);
                    var stlPageSqlContentsElement = stlElement;
                    var stlPageSqlContentsElementReplaceString = stlElement;

                    var whereBuilder = new StringBuilder();
                    if (!string.IsNullOrEmpty(word))
                    {
                        whereBuilder.Append("(");
                        foreach (var type in typeCollection)
                        {
                            whereBuilder.Append($"[{type}] like '%{word}%' OR ");
                        }
                        whereBuilder.Length = whereBuilder.Length - 3;
                        whereBuilder.Append(")");
                    }
                    if (!string.IsNullOrEmpty(dateFrom))
                    {
                        if (whereBuilder.Length > 0)
                        {
                            whereBuilder.Append(" AND ");
                        }
                        whereBuilder.Append($" AddDate >= '{dateFrom}' ");
                    }
                    if (!string.IsNullOrEmpty(dateTo))
                    {
                        if (whereBuilder.Length > 0)
                        {
                            whereBuilder.Append(" AND ");
                        }
                        whereBuilder.Append($" AddDate <= '{dateTo}' ");
                    }
                    if (!string.IsNullOrEmpty(date))
                    {
                        var days = TranslateUtils.ToInt(date);
                        if (days > 0)
                        {
                            if (whereBuilder.Length > 0)
                            {
                                whereBuilder.Append(" AND ");
                            }
                            whereBuilder.Append(SqlUtils.GetDateDiffLessThanDays("AddDate", days.ToString()));
                        }
                    }
                    if (siteId > 0)
                    {
                        if (whereBuilder.Length > 0)
                        {
                            whereBuilder.Append(" AND ");
                        }
                        whereBuilder.Append($"(PublishmentSystemID = {siteId})");
                    }

                    if (whereBuilder.Length > 0)
                    {
                        whereBuilder.Append(" AND ");
                    }
                    whereBuilder.Append("(NodeID > 0) ");

                    var tableName = BaiRongDataProvider.TableCollectionDao.GetFirstTableNameByTableType(EAuxiliaryTableType.BackgroundContent);
                    var arraylist = TranslateUtils.StringCollectionToStringList("ajaxdivid,pagenum,pageindex,iscrosssite,ishighlight,isredirectsingle,isdefaultdisplay,charset,successtemplatestring,failuretemplatestring,word,click,channelid,datefrom,dateto,date,type,siteid");
                    foreach (string key in form.Keys)
                    {
                        if (arraylist.Contains(key.ToLower()))
                        {
                            continue;
                        }
                        if (!string.IsNullOrEmpty(form[key]))
                        {
                            var value = StringUtils.Trim(form[key]);
                            if (!string.IsNullOrEmpty(value))
                            {
                                if (TableManager.IsAttributeNameExists(tableStyle, tableName, key))
                                {
                                    if (whereBuilder.Length > 0)
                                    {
                                        whereBuilder.Append(" AND ");
                                    }
                                    whereBuilder.Append($"([{key}] like '%{value}%')");
                                }
                                else
                                {
                                    if (whereBuilder.Length > 0)
                                    {
                                        whereBuilder.Append(" AND ");
                                    }
                                    whereBuilder.Append($"({ContentAttribute.SettingsXml} like '%{key}={value}%')");
                                }
                            }
                        }
                    }

                    //没搜索条件时不显示搜索结果
                    if (whereBuilder.Length == 0 && isDefaultDisplay == false)
                    {
                        return(Ok(string.Empty));
                    }

                    var stlPageSqlContents = new StlPageSqlContents(stlPageSqlContentsElement, pageInfo, contextInfo, false, false);
                    if (string.IsNullOrEmpty(stlPageSqlContents.DisplayInfo.QueryString))
                    {
                        stlPageSqlContents.DisplayInfo.QueryString =
                            $"SELECT * FROM {tableName} WHERE {whereBuilder}";
                    }
                    stlPageSqlContents.LoadData();

                    int totalNum;
                    var pageCount = stlPageSqlContents.GetPageCount(out totalNum);

                    if (totalNum == 0)
                    {
                        return(NotFound());
                    }
                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex == pageIndex)
                        {
                            var pageHtml     = stlPageSqlContents.Parse(currentPageIndex, pageCount);
                            var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlPageSqlContentsElementReplaceString, pageHtml));

                            StlParserManager.ReplacePageElementsInSearchPage(pagedBuilder, pageInfo, stlLabelList, ajaxDivId, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum);

                            if (isHighlight && !string.IsNullOrEmpty(word))
                            {
                                var pagedContents = pagedBuilder.ToString();
                                pagedBuilder = new StringBuilder();
                                pagedBuilder.Append(RegexUtils.Replace(
                                                        $"({word.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", pagedContents,
                                                        $"<span style='color:#cc0000'>{word}</span>"));
                            }

                            StlUtility.ParseStl(publishmentSystemInfo, pageInfo, contextInfo, pagedBuilder, string.Empty, false);
                            return(Ok(pagedBuilder.ToString()));
                        }
                    }
                }

                StlUtility.ParseStl(publishmentSystemInfo, pageInfo, contextInfo, contentBuilder, string.Empty, false);
                return(Ok(contentBuilder.ToString()));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Ejemplo n.º 26
0
 public string Decrypt(string inputString, string securityKey = null)
 {
     return(TranslateUtils.DecryptStringBySecretKey(inputString, !string.IsNullOrEmpty(securityKey) ? securityKey : SecurityKey));
 }
Ejemplo n.º 27
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _type = Request.QueryString["type"];

            if (IsPostBack)
            {
                return;
            }

            if (StringUtils.EqualsIgnoreCase(_type, TypePreviewImage))
            {
                var siteId          = AuthRequest.GetQueryInt("siteID");
                var siteInfo        = SiteManager.GetSiteInfo(siteId);
                var textBoxClientId = AuthRequest.GetQueryString("textBoxClientID");
                LtlHtml.Text = $@"
<span id=""previewImage""></span>
<script>
var rootUrl = '{PageUtils.GetRootUrl(string.Empty)}';
var siteUrl = '{PageUtils.ParseNavigationUrl($"~/{siteInfo.SiteDir}")}';
var imageUrl = window.parent.document.getElementById('{textBoxClientId}').value;
if(imageUrl && imageUrl.search(/\.bmp|\.jpg|\.jpeg|\.gif|\.png$/i) != -1){{
	if (imageUrl.charAt(0) == '~'){{
		imageUrl = imageUrl.replace('~', rootUrl);
	}}else if (imageUrl.charAt(0) == '@'){{
		imageUrl = imageUrl.replace('@', siteUrl);
	}}
	if(imageUrl.substr(0,2)=='//'){{
		imageUrl = imageUrl.replace('//', '/');
	}}
    $('#previewImage').html('<img src=""' + imageUrl + '"" class=""img-polaroid"" />');
}}
</script>
";
            }
            else if (StringUtils.EqualsIgnoreCase(_type, TypePreviewVideo))
            {
                var siteId          = AuthRequest.GetQueryInt("siteID");
                var siteInfo        = SiteManager.GetSiteInfo(siteId);
                var textBoxClientId = AuthRequest.GetQueryString("textBoxClientID");

                LtlHtml.Text = $@"
<span id=""previewVideo""></span>
<script>
var rootUrl = '{PageUtils.GetRootUrl(string.Empty)}';
var siteUrl = '{PageUtils.ParseNavigationUrl($"~/{siteInfo.SiteDir}")}';
var videoUrl = window.parent.document.getElementById('{textBoxClientId}').value;
if (videoUrl.charAt(0) == '~'){{
	videoUrl = videoUrl.replace('~', rootUrl);
}}else if (videoUrl.charAt(0) == '@'){{
	videoUrl = videoUrl.replace('@', siteUrl);
}}
if(videoUrl.substr(0,2)=='//'){{
	videoUrl = videoUrl.replace('//', '/');
}}
if (videoUrl){{
    $('#previewVideo').html('<embed src=""../assets/player.swf"" allowfullscreen=""true"" flashvars=""controlbar=over&autostart=true&file='+videoUrl+'"" width=""{450}"" height=""{350}""/>');
}}
</script>
";
            }
            else if (StringUtils.EqualsIgnoreCase(_type, TypePreviewVideoByUrl))
            {
                var siteId   = AuthRequest.GetQueryInt("siteID");
                var siteInfo = SiteManager.GetSiteInfo(siteId);
                var videoUrl = AuthRequest.GetQueryString("videoUrl");

                LtlHtml.Text = $@"
<embed src=""../assets/player.swf"" allowfullscreen=""true"" flashvars=""controlbar=over&autostart=true&file={PageUtility
                    .ParseNavigationUrl(siteInfo, videoUrl, true)}"" width=""{450}"" height=""{350}""/>
";
            }
            else
            {
                LtlHtml.Text = TranslateUtils.DecryptStringBySecretKey(Request.QueryString["html"]);
            }
        }
        public void Main()
        {
            var builder = new StringBuilder();

            try
            {
                var form                = HttpContext.Current.Request.Form;
                var siteId              = TranslateUtils.ToInt(form["siteId"]);
                var parentId            = TranslateUtils.ToInt(form["parentId"]);
                var target              = form["target"];
                var isShowTreeLine      = TranslateUtils.ToBool(form["isShowTreeLine"]);
                var isShowContentNum    = TranslateUtils.ToBool(form["isShowContentNum"]);
                var currentFormatString = form["currentFormatString"];
                var topChannelId        = TranslateUtils.ToInt(form["topChannelId"]);
                var topParentsCount     = TranslateUtils.ToInt(form["topParentsCount"]);
                var currentChannelId    = TranslateUtils.ToInt(form["currentChannelId"]);

                var siteInfo      = SiteManager.GetSiteInfo(siteId);
                var channelIdList = ChannelManager.GetChannelIdList(ChannelManager.GetChannelInfo(siteId, parentId == 0 ? siteId : parentId), EScopeType.Children, string.Empty, string.Empty, string.Empty);

                foreach (var channelId in channelIdList)
                {
                    var nodeInfo = ChannelManager.GetChannelInfo(siteId, channelId);

                    builder.Append(StlTree.GetChannelRowHtml(siteInfo, nodeInfo, target, isShowTreeLine, isShowContentNum, TranslateUtils.DecryptStringBySecretKey(currentFormatString), topChannelId, topParentsCount, currentChannelId, false));
                }
            }
            catch
            {
                // ignored
            }

            HttpContext.Current.Response.Write(builder);
            HttpContext.Current.Response.End();
        }
Ejemplo n.º 29
0
 public void BtnReturn_OnClick(object sender, EventArgs e)
 {
     PageUtils.Redirect(TranslateUtils.DecryptStringBySecretKey(AuthRequest.GetQueryString("returnUrl")));
 }
        public IHttpActionResult Main()
        {
            PageInfo pageInfo = null;
            var      template = string.Empty;

            try
            {
                var request = new RequestImpl();
                var form    = GetPostCollection(request);

                var isAllSites    = request.GetPostBool(StlSearch.IsAllSites.ToLower());
                var siteName      = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.SiteName.ToLower()));
                var siteDir       = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.SiteDir.ToLower()));
                var siteIds       = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.SiteIds.ToLower()));
                var channelIndex  = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.ChannelIndex.ToLower()));
                var channelName   = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.ChannelName.ToLower()));
                var channelIds    = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.ChannelIds.ToLower()));
                var type          = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.Type.ToLower()));
                var word          = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.Word.ToLower()));
                var dateAttribute = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.DateAttribute.ToLower()));
                var dateFrom      = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.DateFrom.ToLower()));
                var dateTo        = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.DateTo.ToLower()));
                var since         = AttackUtils.FilterSqlAndXss(request.GetPostString(StlSearch.Since.ToLower()));
                var pageNum       = request.GetPostInt(StlSearch.PageNum.ToLower());
                var isHighlight   = request.GetPostBool(StlSearch.IsHighlight.ToLower());
                var siteId        = request.GetPostInt("siteid");
                var ajaxDivId     = AttackUtils.FilterSqlAndXss(request.GetPostString("ajaxdivid"));
                template = TranslateUtils.DecryptStringBySecretKey(request.GetPostString("template"));
                var pageIndex = request.GetPostInt("page", 1) - 1;

                var templateInfo = new TemplateInfo(0, siteId, string.Empty, TemplateType.FileTemplate, string.Empty, string.Empty, string.Empty, ECharset.utf_8, false);
                var siteInfo     = SiteManager.GetSiteInfo(siteId);
                pageInfo = new PageInfo(siteId, 0, siteInfo, templateInfo, new Dictionary <string, object>())
                {
                    UserInfo = request.UserInfo
                };
                var contextInfo    = new ContextInfo(pageInfo);
                var contentBuilder = new StringBuilder(StlRequestEntities.ParseRequestEntities(form, template));

                var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString());

                if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList))
                {
                    var stlElement             = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlLabelList);
                    var stlPageContentsElement = stlElement;
                    var stlPageContentsElementReplaceString = stlElement;

                    var whereString = DataProvider.ContentDao.GetWhereStringByStlSearch(isAllSites, siteName, siteDir, siteIds, channelIndex, channelName, channelIds, type, word, dateAttribute, dateFrom, dateTo, since, siteId, ApiRouteActionsSearch.ExlcudeAttributeNames, form);

                    var stlPageContents = new StlPageContents(stlPageContentsElement, pageInfo, contextInfo, pageNum, siteInfo.TableName, whereString);
                    var pageCount       = stlPageContents.GetPageCount(out var totalNum);
                    if (totalNum == 0)
                    {
                        return(NotFound());
                    }

                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex != pageIndex)
                        {
                            continue;
                        }

                        var pageHtml     = stlPageContents.Parse(totalNum, currentPageIndex, pageCount, false);
                        var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlPageContentsElementReplaceString, pageHtml));

                        StlParserManager.ReplacePageElementsInSearchPage(pagedBuilder, pageInfo, stlLabelList, ajaxDivId, pageInfo.PageChannelId, currentPageIndex, pageCount, totalNum);

                        if (isHighlight && !string.IsNullOrEmpty(word))
                        {
                            var pagedContents = pagedBuilder.ToString();
                            pagedBuilder = new StringBuilder();
                            pagedBuilder.Append(RegexUtils.Replace(
                                                    $"({word.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", pagedContents,
                                                    $"<span style='color:#cc0000'>{word}</span>"));
                        }

                        Parser.Parse(pageInfo, contextInfo, pagedBuilder, string.Empty, false);
                        return(Ok(pagedBuilder.ToString()));
                    }
                }
                else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlLabelList))
                {
                    var stlElement = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlLabelList);

                    var stlPageSqlContents = new StlPageSqlContents(stlElement, pageInfo, contextInfo);

                    var pageCount = stlPageSqlContents.GetPageCount(out var totalNum);
                    if (totalNum == 0)
                    {
                        return(NotFound());
                    }

                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex != pageIndex)
                        {
                            continue;
                        }

                        var pageHtml     = stlPageSqlContents.Parse(totalNum, currentPageIndex, pageCount, false);
                        var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElement, pageHtml));

                        StlParserManager.ReplacePageElementsInSearchPage(pagedBuilder, pageInfo, stlLabelList, ajaxDivId, pageInfo.PageChannelId, currentPageIndex, pageCount, totalNum);

                        if (isHighlight && !string.IsNullOrEmpty(word))
                        {
                            var pagedContents = pagedBuilder.ToString();
                            pagedBuilder = new StringBuilder();
                            pagedBuilder.Append(RegexUtils.Replace(
                                                    $"({word.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", pagedContents,
                                                    $"<span style='color:#cc0000'>{word}</span>"));
                        }

                        Parser.Parse(pageInfo, contextInfo, pagedBuilder, string.Empty, false);
                        return(Ok(pagedBuilder.ToString()));
                    }
                }

                Parser.Parse(pageInfo, contextInfo, contentBuilder, string.Empty, false);
                return(Ok(contentBuilder.ToString()));
            }
            catch (Exception ex)
            {
                var message = LogUtils.AddStlErrorLog(pageInfo, StlSearch.ElementName, template, ex);
                return(BadRequest(message));
            }
        }