public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            var url = (string)context.Request["url"];
            var title = context.Request["title"];
            var sWidgetID = context.Request["widgetID"];
            _buttonClass = context.Request["buttonColor"];

            var widgetID = 1;

            int.TryParse(sWidgetID, out widgetID);

            if (widgetID == 0)
                widgetID = 1;

            if (string.IsNullOrEmpty(url))
                return;

            var service = new com.dailyez.Service();

            var reader = new StreamReader(new FileStream(System.Web.HttpContext.Current.Server.MapPath("stackSelectorTemplate.html"), FileMode.Open, FileAccess.Read, FileShare.Read));
            var template = reader.ReadToEnd();
            reader.Close();

            template = template.Replace("[%URL%]", url);
            template = template.Replace("[%TITLE%]", title);
            template = template.Replace("[%WIDGET-ID%]", widgetID + "");
            template = template.Replace("[%BUTTON-CLASS%]", _buttonClass);

            context.Response.Write(template);
        }
Ejemplo n.º 2
0
        private void BasePagePreInit(object sender, EventArgs e)
        {
            WebService = new com.dailyez.Service();

            int clientID = Utility.GetIntFromCookie(Request, "clientID");
            if (HttpContext.Current.IsDebuggingEnabled)
                clientID = 1;
            if (clientID == 0)
            {
                //DON'T TOUCH ANYTHING BETWEEN THESE LINES
                //---------------------------------------------------
                var url = Request.Url.ToString();
                Uri uri = new Uri(url);

                //url = url.Remove(url.LastIndexOf("/", StringComparison.Ordinal)).Replace("/DailyEZ", "").Replace("/widgets", "");
                url = "http://" + uri.Host;
                //url = "http://mary.dailyez.com";
                var dailyEZ = Uow.DailyEZs.GetAll().FirstOrDefault(d => d.UserFriendlyUrl.ToLower() == url.ToLower());
                if (dailyEZ != null)
                    clientID = dailyEZ.ClientId;
                //---------------------------------------------------

                if (clientID == 0)
                {
                    //add lines here
                    if (url.Contains("mononawirestaurants.com"))
                        clientID = 826;
                    //COPY THESE LINES
                    //***********************
                    else if (url.Contains("cottagegroverestaurants.com"))
                        clientID = 999;
                    //***********************
                    else if (url == "http://wisconsinrecallelection.com" || url.Contains("Single-Site-Pages"))
                        clientID = 790; //set it to SC Wis

                    //else
                    //    Response.Redirect("~/ErrorPage.aspx?errorMessage=No ClientID found for " +
                    //                      HttpUtility.UrlEncode(url));
                }
            }
            if (clientID == 0)
            {
                Elmah.ErrorLog.GetDefault(HttpContext.Current).Log(new Error(new NullReferenceException("BasePage.ClientID still 0 after checks")));
                return;
            }
            JetNettClient = Uow.Clients.GetById(clientID);
            if (JetNettClient == null)
            {
                Response.Write("No Client exists for ID: " + clientID);
                return;
            }

            DailyEZObject1 = Uow.DailyEZs.GetAll().SingleOrDefault(d => d.ClientId == JetNettClient.Id);
            if (DailyEZObject1 == null)
            {
                Response.Write("There is no DailyEZ associated with this Client.  ID: " + clientID);
            }

            DailyEZObject = WebService.GetDailyEZByClientID(ConfigurationManager.AppSettings["webServiceKey"], clientID);
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            var stackID = context.Request["stackID"];

            var service = new com.dailyez.Service();
            var stack = service.GetStack(int.Parse(stackID));

            context.Response.Write(stack.Height);
        }
Ejemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            var stacks = (string)context.Request["stacks"];
            var title = context.Request["title"];
            var sWidgetID = context.Request["widgetID"];
            _buttonClass = context.Request["buttonColor"];

            var widgetID = 1;

            int.TryParse(sWidgetID, out widgetID);

            if (widgetID == 0)
                widgetID = 1;

            if (stacks == null)
                return;
            string[] iStacks = stacks.Split(new char[] { ',' });
            var service = new com.dailyez.Service();

            var stacksList = new List<com.dailyez.Stack>();
            foreach (var s in iStacks)
            {
                var stackID = 0;
                int.TryParse(s, out stackID);
                if (stackID > 0)
                {
                    stacksList.Add(service.GetStack(stackID));
                }
            }

            var reader = new StreamReader(new FileStream(System.Web.HttpContext.Current.Server.MapPath("stackSelectorTemplate.html"), FileMode.Open, FileAccess.Read, FileShare.Read));
            var template = reader.ReadToEnd();
            reader.Close();

            template = template.Replace("[%STACKS%]", GetStacksHtml(stacksList));
            template = template.Replace("[%TITLE%]", title);
            template = template.Replace("[%WIDGET-ID%]", widgetID + "");
            template = template.Replace("[%BUTTON-CLASS%]", _buttonClass);

            context.Response.Write(template);
        }
Ejemplo n.º 5
0
        public static void SetCookies(HttpRequest request, HttpResponse response)
        {
            int clientID = Convert.ToInt32(request.QueryString["clientID"]);

            if (clientID == 0)
            {
                string url = request.Url.ToString();
                url = url.Remove(url.LastIndexOf("/")).Replace("/v2", "");

                com.dailyez.Service service = new com.dailyez.Service();

                clientID = service.GetClientIDFromUserFriendlyURL(ConfigurationManager.AppSettings["webServiceKey"], url);

            }

            int index = Convert.ToInt32(request.QueryString["index"]);
            int euID = Convert.ToInt32(request.QueryString["euID"]);
            string browserType = request.QueryString["browserType"];
            int id1 = Convert.ToInt32(request.QueryString["id1"]);
            int id2 = Convert.ToInt32(request.QueryString["id2"]);
            int tab = Convert.ToInt32(request.QueryString["tab"]);
            if (clientID > 0)
                SaveCookie(response, request, "clientID", "" + clientID);

            if (index > 0)
                SaveCookie(response, request, "index", "" + index);

            if (euID > 0)
                SaveCookie(response, request, "euID", "" + euID);
            if (browserType != null)
                SaveCookie(response, request, "browserType", "" + browserType);

            if (id1 > 0)
                SaveCookie(response, request, "id1", "" + id1);

            if (id2 > 0)
                SaveCookie(response, request, "id2", "" + id2);
            if (tab > 0)
                SaveCookie(response, request, "tab", "" + tab);
        }
Ejemplo n.º 6
0
        public static List<int> SearchAds(string query)
        {
            //init
            com.dailyez.Service service = new com.dailyez.Service();
            com.dailyez.Ads[] ads = service.GetAllAds(ConfigurationManager.AppSettings["webServiceKey"]);

            List<int> results = new List<int>();
            if (query == null)
                return results;
            //loop through all ads
            foreach (com.dailyez.Ads ad in ads)
            {
                //extract all the tags from the add
                string[] tags = SeperateTags(ad.Tags);
                foreach (string tag in tags)
                {
                    if (tag == "")
                        continue;
                    if ((tag.Trim().ToLower() == query.Trim().ToLower()) ||
                        (tag.Trim().ToLower().Contains(query.Trim().ToLower())) ||
                        (query.Trim().ToLower().Contains(tag.Trim().ToLower())))
                        results.Add(ad.ID);
                    //add the tag to the dictionary table
                }
            }

            return results;
        }
Ejemplo n.º 7
0
        public static string GetClientName(HttpRequest request)
        {
            int clientID = 0;
            clientID = GetIntFromCookie(request, "clientID");

            com.dailyez.Service service = new com.dailyez.Service();
            com.dailyez.Client client = service.GetClient(ConfigurationManager.AppSettings["webServiceKey"], clientID);

            if (client != null)
                return client.Name;
            else
                return "Invalid Client Identifier";
        }
Ejemplo n.º 8
0
        public string HtmSearchQuery(string search)
        {
            PSearch = search;
            var words = search.Split(new char[] { ' ' });

            var clientID = Utility.GetIntFromCookie(Request, "clientID");
            var euID = Utility.GetIntFromCookie(Request, "euID");

            var service = new com.dailyez.Service();
            var dailyEZ = BasePage.DailyEZObject;

            var response = "";

            //     int[] test = {1, 2, 415};

            var searchResults = _searchService.Search(GetFoldersToSearch(dailyEZ), search);

            //start our html
            response += "<div class='leftColumnContent'>";

            //make a dictionary to store the duplicates
            Dictionary<string, List<SearchService.SearchResult>> dictionary = MakeSearchDictionaries(searchResults);

            //create a list for the headers
            var headers = new List<SearchService.SearchResult>();

            //create a new list of KeyValuePairs<string, SearchResult's List>.  This is done so we can easily sort the values
            var myList = new List<KeyValuePair<string, List<SearchService.SearchResult>>>(dictionary);

            //change header titles before sort
            FormatHeaderTitles(myList);

            //our sorting function, takes the first pair, and comparies the link title to the second pair's link title.
            myList.Sort(
                delegate(KeyValuePair<string, List<SearchService.SearchResult>> firstPair, KeyValuePair<string, List<SearchService.SearchResult>> secondPair)
                {
                    //return firstPair.Value[0].Link_Title.CompareTo(secondPair.Value[0].Link_Title);
                    return PageRank(search, secondPair.Value).CompareTo(PageRank(search, firstPair.Value));
                }
                );

            //position go till we can't anymore
            var divIndex = 0;
            foreach (KeyValuePair<string, List<SearchService.SearchResult>> e in myList)
            {
                if (e.Value.Count >= 1)
                {
                    var link = new com.dailyez.Link
                        {
                            Title = e.Value[0].Link_Title,
                            URL = e.Value[0].Link_URL,
                            Target = ""
                        };

                    var oneIsLink = false;

                    //for every SearchResult inside the list of the current dictionary value
                    foreach (SearchService.SearchResult r in e.Value)
                    {
                        //find out if at least one of them is a hyperlink
                        if (r.Link_URL.Length > 5)
                        {
                            oneIsLink = true;
                            break;
                        }
                    }

                    //one of the values is a hyperlink...make the starting div
                    if (oneIsLink)
                    {
                        if (Debug == true)
                            response += "<span style='color:red'>" + PageRank(search, e.Value) + "</span>";
                        response += Utility.GetA(link) + " " + e.Value.Count + " pages ";
                        response += "<span style='font-size:8pt; cursor:pointer; color:blue;' onclick=\"javascript:document.getElementById('resultsDiv" + divIndex + "').style.display = 'block';\">show</span>&nbsp;&nbsp;";
                        response += "<span style='font-size:8pt; cursor:pointer; color:blue;' onclick=\"javascript:document.getElementById('resultsDiv" + divIndex + "').style.display = 'none';\">hide</span><br/>";

                        //  <div id='resultsDiv[X]' style='display:none;font-family:Arial'>
                        response += "<div id='resultsDiv" + divIndex + "' style='display:none;font-family:Arial;line-spacing:20px; margin-left:10px;'>";
                    }

                    //body of the div
                    foreach (var result in e.Value)
                    {
                        if (result.Link_URL.Length > 5)
                        {
                            var innerLink = new com.dailyez.Link
                                {
                                    Title = result.Page_Title,
                                    URL = "" + result.Page_ID,
                                    Target = ""
                                };
                            response += Utility.GetA(innerLink) + "<br/>";
                        }
                        else
                        {
                            var innerLink = new com.dailyez.Link
                                {
                                    Title = result.Link_Title,
                                    URL = "" + result.Page_ID,
                                    Target = ""
                                };
                            // innerLink.Title = result.Link_Title + " - " + service.GetPage(ConfigurationManager.AppSettings["webServiceKey"], result.Page_ID).Title;
                            response += Utility.GetA(innerLink) + "<br/>";
                            //   headers.Add(result);
                        }

                    }
                    if (oneIsLink)
                        response += "</div>";
                    divIndex++;

                }
                else
                {
                    if (e.Value[0].Link_URL.Length > 5)
                    {
                        var link = new com.dailyez.Link();
                        link.Title = e.Value[0].Link_Title;
                        link.URL = e.Value[0].Link_URL;
                        link.Target = "";
                        var pageLink = new com.dailyez.Link();
                        pageLink.Title = e.Value[0].Page_Title;
                        pageLink.URL = "" + e.Value[0].Page_ID;
                        response += Utility.GetA(link) + " @ " + Utility.GetA(pageLink) + "<br/>";
                    }
                    else
                    {
                        var innerLink = new com.dailyez.Link();
                        // innerLink.Title = result.Link_Title + " - " + service.GetPage(ConfigurationManager.AppSettings["webServiceKey"], result.Page_ID).Title;
                        innerLink.Title = "" + e.Value[0].Link_Title;
                        innerLink.URL = "" + e.Value[0].Page_ID;
                        innerLink.Target = "";
                        response += Utility.GetA(innerLink) + "<br/>";

                        //commented out add headers here
                    }

                }
            }

            //add headers
            var srHeaders = Utility.ConvertToLocalSearchResult(headers.ToArray());
            var headerList = new List<SearchResult>(srHeaders);
            headerList.Sort();
            foreach (SearchResult result in headerList)
            {
                var innerLink = new com.dailyez.Link
                    {
                        Title = result.Page_Title + " - " + result.Link_Title,
                        URL = "" + result.Page_ID,
                        Target = ""
                    };
                //   response += DailyEZUtility.GetA(innerLink) + "<br/>";
            }

            if (response.Length < 1)
                response = "<span style='font-family:arial; font-size:12pt;'>Sorry, No Search Results.</span>";

            //-search ads
            SearchService.Ad_Assignment[] ads = _searchService.SearchAds(search);

            foreach (SearchService.Ad_Assignment a in ads)
            {
                if (a.Ad_ID != null)
                    response += "<a href=\"http://www.ezcontrolpanel.com/Ad/ViewAd/" + a.Ad_ID + "\" target=\"_blank\">" + HttpUtility.HtmlEncode(_searchService.GetAd(a.Ad_ID.Value).Name) + "</a><br/>";
            }

            response += "</div>";

            response += "<div class='rightColumnContent' style='border:none;'>";
            response += "</div><div style='clear:right;'></div><div style='background-color:white; margin-top:-80px; text-align:right; border:none;' class='rightColumnContent'>";

            var litAds = new Literal();
            Renderer.RenderJetNettAdsToLiteral(litAds, Request);

            response += "<br/><div style='float:right;line-height:normal;'>" + litAds.Text + "</div>";
            response += "</div>";
            return response;
        }
Ejemplo n.º 9
0
        protected string GetAdGroupHtml(int adGroup, bool autoRotate, HttpContext context)
        {
            var service = new com.dailyez.Service();

            int pageID = 0;

            com.dailyez.AdGroup group = service.GetAdGroup(ConfigurationManager.AppSettings["webServiceKey"], adGroup);
            com.dailyez.Ad_Assignments[] ads = service.GetAdAssignmentsByAdGroup(adGroup);

            var htm = "";
            if (ads.Length == 0)
                return "No Ads in this Group";

            if (!autoRotate)
                group.Seed = 0;
            for (var i = 0; i < group.Viewport_Size; i++)
            {

                var adFound = false;
                var currentAd = 0;

                //current display ad +
                currentAd = (group.Seed + i) % ads.Length;
                while (!adFound)
                {
                    if (ads[currentAd].Ad_Mode == 2)
                    {
                        if (autoRotate)
                            group.Seed += 1;
                        currentAd = (group.Seed + i) % ads.Length;
                    }
                    else if (ads[currentAd].Ad_Mode == 1)
                    {
                        var startDate = new System.DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, 1);
                        var endDate = new System.DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, System.DateTime.DaysInMonth(System.DateTime.Now.Year, System.DateTime.Now.Month));
                        com.dailyez.Ad_View_Tracker[] tracker = service.GetAdViewReport(ConfigurationManager.AppSettings["webServiceKey"], startDate, endDate, ads[currentAd].ID, null, null);

                        //if the ad is over the limit
                        if (ads[currentAd].Ad_Limit <= tracker.Length)
                        {
                            //increase the seed if the ad is rotating
                            if (autoRotate)
                                group.Seed += 1;

                            //make the current ad the next ad in the group

                            //make sure we're not resetting to the same ad number...otherwise we'll never get out of this loop
                            int tempID = 0;
                            tempID = currentAd;
                            currentAd = (group.Seed + i) % ads.Length;

                            //just set the ad found to be true so we eventually get out of here
                            if (currentAd == tempID)
                                adFound = true;
                        }
                        else
                            adFound = true;
                    }
                    else
                        adFound = true;
                }

                com.dailyez.Ads_Model ad = null;

                if (ads[currentAd].Ad_ID > 0)
                    ad = service.GetAdsModel(ads[currentAd].Ad_ID);

                if (ad != null)
                {
                    htm += "<div class=\"divAd\" id=\"placementID" + ads[currentAd].ID + "\" style='width:300px; height:" + ad.Ad_Height + "px;border:" + ad.Border_Style + ";'>" + ad.Html + "</div><br/>";
                }

                //track ad view
                var adLog = new Utility.AdLog();
                adLog.DeleteOldViewLogs();
                if (!adLog.ShouldRecordView(context.Request.ServerVariables["REMOTE_ADDR"], ads[currentAd].ID)) continue;

                //pass in the placementID rather than the adID
                adLog.Log(ads[currentAd].ID, pageID, Code.Utility.GetIntFromCookie(context.Request, "clientID"), Code.Utility.GetStringFromCookie(context.Request, "zip"), Code.Utility.GetStringFromCookie(context.Request, "registered2").Equals("true"));
            }

            service.IncrementAdGroupSeed(ConfigurationManager.AppSettings["webServiceKey"], group.ID);
            return htm;
        }
Ejemplo n.º 10
0
        private void GetLinks(int pageID, bool oneColumn, out string leftSideLinks, out string rightSideLinks, out string pageTitle, out string header, out string footer)
        {
            var id = pageID;

            //if (maxColWidth > 0)
            //{
            //    leftColWidth.Text = "width:" + maxColWidth + "px; overflow:hidden;white-space:nowrap;";
            //    rightColWidth.Text = "width:" + maxColWidth + "px; overflow:hidden;white-space:nowrap;";
            //}
            leftSideLinks = "";
            rightSideLinks = "";
            pageTitle = "";
            header = "";
            footer = "";

            if (id == 0)
                return;

            var service = new com.dailyez.Service();
            var page = service.GetPage(ConfigurationManager.AppSettings["webServiceKey"], id);

            pageTitle = page.Title;
            header = page.Extra_HTML;
            footer = page.Footer_HTML;

            var links = service.GetLinksFromPage(ConfigurationManager.AppSettings["webServiceKey"], id);

            if (page.Auto_Ordering)
                Code.Utility.BubbleSortList(links);

            var leftLinks = "";
            var rightLinks = "";
            var tmp = "";

            var style = "";
            if (oneColumn)
            {
                foreach (var link in links)
                {
                    if (link.IsLink)
                    {
                        tmp += CreateATag(link);
                        tmp += "<br/>";
                    }
                    else
                    {
                        tmp += string.Format("<span style=\"{0}\" class=\"header\"><h2 style='font-size:16px; margin:0;'>{1}</h2></span>", GetStyle(link.Title), FormatTitle(link.Title));
                        tmp += "<br/>";
                    }
                }
                leftLinks = tmp;
            }
            else
            {
                var colLength = links.Length / 2;

                if (((links.Length) % 2) == 1)
                    colLength++;
                var counter = 0;
                foreach (var link in links)
                {
                    if (link.IsLink)
                    {
                        tmp += GetFavIconHtml(link.URL, _favIcons) + CreateATag(link);
                        tmp += "<br/>";
                    }
                    else
                    {
                        tmp += string.Format("<span style=\"{0}\" class=\"header\"><h2 style='font-size:14px; line-height:20px; margin:0;'>{1}</h2></span>", GetStyle(link.Title), FormatTitle(link.Title));
                    }

                    counter++;

                    if (counter != colLength) continue;
                    leftLinks = tmp;
                    tmp = "";
                }
                rightLinks = tmp;
            }
            leftSideLinks = leftLinks;
            rightSideLinks = rightLinks;
        }