public FileAmazonS3(long siteId) { //if the site has its own bucket name then use it, else get from he main configuration SiteLibrary lib = new SiteLibrary(); AWAPI_Data.Data.awSite site = lib.Get(siteId); if (site != null && !String.IsNullOrEmpty(site.fileAmazonS3BucketName)) { BucketName = site.fileAmazonS3BucketName; } else { BucketName = ConfigurationLibrary.Config.fileAmazonS3BucketName; } }
/// <summary> /// Returns true if the referrer has right... /// </summary> /// <param name="siteId"></param> /// <returns></returns> public static bool IsValidReferrer(long siteId) { if (siteId <= 0) { return(false); } AWAPI_BusinessLibrary.library.SiteLibrary _siteLib = new SiteLibrary(); AWAPI_Data.Data.awSite site = _siteLib.Get(siteId); //check if site doesn't exist or disabled if (site == null || !site.isEnabled) { return(false); } string domain = System.Web.HttpContext.Current.Request.UrlReferrer.Authority;// = "localhost:56624"; //check if the domain is granted if (!String.IsNullOrEmpty(site.grantedDomains)) { string[] grantedDomains = site.grantedDomains.Split(','); foreach (string dmn in grantedDomains) { if (dmn.Trim().ToLower().Replace("www.", "").Replace("https://", "").Replace("http://", "") == domain.ToLower()) { return(true); } } return(false); } //check if the domain is banned if (!String.IsNullOrEmpty(site.bannedDomains)) { string[] bannedDomains = site.bannedDomains.Split(','); foreach (string dmn in bannedDomains) { if (dmn.Trim().ToLower().Replace("www.", "").Replace("https://", "").Replace("http://", "") == domain.ToLower()) { return(false); } } } return(true); }
/// <summary> /// Access Key is required for insert/update methods, /// (We cannot get client's IP address from WCF) /// </summary> /// <param name="siteId"></param> /// <param name="accessKey"></param> /// <returns></returns> public static bool IsValidAccessKey(long siteId, string accessKey) { if (siteId <= 0 || String.IsNullOrEmpty(accessKey)) { return(false); } AWAPI_BusinessLibrary.library.SiteLibrary _siteLib = new SiteLibrary(); AWAPI_Data.Data.awSite site = _siteLib.Get(siteId); //check if site doesn't exist or disabled if (site == null || !site.isEnabled) { return(false); } if (site.accessKey.ToLower() == accessKey.ToLower()) { return(true); } return(false); }
public void ProcessRequest(HttpContext context) { if (SiteId <= 0) { return; } AWAPI_Data.Data.awSite site = _siteLib.Get(SiteId); if (site == null || !site.isEnabled || String.IsNullOrEmpty(site.twitterUsername) || String.IsNullOrEmpty(site.twitterPassword)) { return; } string username = site.twitterUsername; string password = new AWAPI_Common.library.SecurityLibrary().DecodeString(site.twitterPassword); _feed = new SyndicationFeed("AWAPI CMS Twitter Feed", "", null); _feed.Authors.Add(new SyndicationPerson(username)); _feed.Categories.Add(new SyndicationCategory("tweets")); _feed.AttributeExtensions.Add(new XmlQualifiedName("pagesize"), PageSize.ToString()); switch (MethodName) { case "getstatus": break; case "getstatuslist": GetStatusList(username, password, PageSize); break; } //TRANSFORM THE OUTPUT ----------------------------------------------------------------- string output = ""; XmlWriter writer = XmlWriter.Create(context.Response.Output); if (_feed != null) { switch (ReturnType) { case "atom": context.Response.ContentType = "application/atom+xml"; _feed.Description = new TextSyndicationContent("AWAPI Twitter in Atom 1.0 Feed Format"); Atom10FeedFormatter atom = new Atom10FeedFormatter(_feed); atom.WriteTo(writer); break; case "json": context.Response.ContentType = "application/json"; Rss20FeedFormatter rssFeed = new Rss20FeedFormatter(_feed); if (rssFeed != null) { output = Newtonsoft.Json.JsonConvert.SerializeObject(rssFeed); } break; default: //rss _feed.Description = new TextSyndicationContent("AWAPI Twitter in RSS 2.0 Feed Format"); context.Response.ContentType = "application/rss+xml"; Rss20FeedFormatter rss = new Rss20FeedFormatter(_feed); rss.WriteTo(writer); break; } } if (output != "") { context.Response.Write(output); } writer.Close(); }