Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        /// <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);
        }
        public void ProcessRequest(HttpContext context)
        {
            AWAPI_Data.Data.awSite site = null;
            if (SiteId != 0)
            {
                site = new AWAPI_BusinessLibrary.library.SiteLibrary().Get(SiteId);
            }

            if (site == null)
            {
                return;
            }


            _feed = new SyndicationFeed("AWAPI CMS Feed", "", null);
            _feed.Authors.Add(new SyndicationPerson(""));
            _feed.Categories.Add(new SyndicationCategory("weatherforecast"));
            _feed.AttributeExtensions.Add(new XmlQualifiedName("site"), site.title);
            _feed.AttributeExtensions.Add(new XmlQualifiedName("sitelink"), site.link);

            if (City != "" && WeatherServiceUrl != "")
            {
                switch (WeatherServiceProvider.ToLower())
                {
                case "google":
                    GetFromGoogle(WeatherServiceUrl + City);
                    break;

                default:
                    break;
                }
            }

            XmlWriter writer = XmlWriter.Create(context.Response.Output);

            context.Response.ContentType = "application/rss+xml";
            Rss20FeedFormatter rss = new Rss20FeedFormatter(_feed);

            rss.WriteTo(writer);
            writer.Close();
        }
Beispiel #4
0
        /// <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);
        }
Beispiel #5
0
        void PopulateUser(long userId)
        {
            ResetControls();

            AWAPI_Data.CustomEntities.UserExtended user = new AWAPI_Data.CustomEntities.UserExtended();
            user = _userLib.Get(userId);

            if (user == null)
            {
                return;
            }

            _userName.Text        = user.username;
            _email.Text           = user.email.Trim();
            _userId.Text          = user.userId.ToString();
            _firstName.Text       = user.firstName.Trim();
            _lastName.Text        = user.lastName.Trim();
            _password.Text        = user.password.Trim();
            _confirmPassword.Text = user.password.Trim();
            _description.Text     = user.description;
            _imageUrl.Text        = user.imageurl;
            _image.ImageUrl       = AWAPI_BusinessLibrary.library.FileLibrary.GetUrl(user.imageurl, "150x150"); // user.imageurl + "&size=150x150";
            _enabled.Checked      = user.isEnabled;
            _isSuperAdmin.Checked = user.isSuperAdmin;

            if (user.gender != null && _gender.Items.FindByValue(user.gender) != null)
            {
                _gender.SelectedValue = user.gender;
            }
            if (user.birthday != null)
            {
                _birthday.Text = user.birthday.Value.ToString("MM/dd/yyyy");
            }
            _tel.Text        = user.tel;
            _tel2.Text       = user.tel2;
            _address.Text    = user.address;
            _city.Text       = user.city;
            _province.Text   = user.state;
            _postalCode.Text = user.postalcode;
            _country.Text    = user.country;

            //check tag's sites:
            AWAPI_BusinessLibrary.library.SiteLibrary siteLib = new AWAPI_BusinessLibrary.library.SiteLibrary();
            var usersSites = siteLib.GetUserSiteList(userId);

            if (usersSites != null)
            {
                for (int n = 0; n < _siteList.Items.Count; n++)
                {
                    _siteList.Items[n].Selected = false;
                    _siteList.Items[n].Enabled  = true;
                    //_siteList.Items[n].Text.Replace(SITE_OWNER, "");

                    long siteId = Convert.ToInt64(_siteList.Items[n].Value);
                    var  sites  = from s in usersSites
                                  where s.siteId.Equals(siteId)
                                  select s;
                    if (sites != null && sites.Count() > 0)
                    {
                        _siteList.Items[n].Selected = true;
                        AWAPI_Data.Data.awSite site = new AWAPI_Data.Data.awSite();
                        site = sites.FirstOrDefault <AWAPI_Data.Data.awSite>();
                        if (site.userId == userId)
                        {
                            _siteList.Items[n].Enabled = false;
                            //_siteList.Items[n].Text += SITE_OWNER;
                        }
                    }
                }
            }

            ShowHideControls(true);
        }
Beispiel #6
0
        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();
        }