Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.EarnersRoleEnabled && AppSettings.TitanFeatures.EarnLikesEnabled && Member.CurrentInCache.IsEarner);
        DisplayMessage();

        LabelInfo.Text = L1.CONNECTWITHFACEBOOK;
        User           = Member.CurrentInCache;

        //Get codes
        BodyCode = FacebookMember.GetJSStartingCode();

        if (FacebookMember.Logged() != null)
        {
            LabelInfo.Text = L1.YOUCONNECTEDWITHFACEBOOK;
            FbUser         = new FacebookMember(FacebookMember.Logged());

            //Facebook security (banning multiple accounts instantly)
            User.FacebookName = FbUser.Name;
            User.Save();

            AntiCheatSystem.AfterFacebookLogin(User);
            FacebookLikesGridView.Visible = MyFriendsPlaceHolder.Visible = true;
            FacebookLoginPanel.Visible    = false;
        }
        else
        {
            FacebookLikesGridView.Visible = MyFriendsPlaceHolder.Visible = false;
        }

        FacebookLikesGridView.DataBind();

        if (AppSettings.Facebook.CustomFacebookLikesEnabled)
        {
            FacebookLikesGridView.Columns[4].HeaderText = U6012.REWARDFORLIKES;
            CustomLikesInfoLabel.Text = U6012.CUSTOMLIKESINFO;
        }
    }
Beispiel #2
0
    public static string LikeUnlike(string adId, bool credit)
    {
        string succMsg = string.Empty;

        if (FacebookMember.Logged() != null)
        {
            Member         User = Member.Current;
            FacebookMember FbUser;
            FacebookAdvert Ad = new FacebookAdvert(Convert.ToInt32(adId));

            FbUser = new FacebookMember(FacebookMember.Logged());

            //Facebook security (banning multiple accounts instantly)
            User.FacebookName = FbUser.Name;
            User.Save();

            AntiCheatSystem.AfterFacebookLogin(User);

            if (FbUser == null)
            {
                return(U5008.MUSTCONNECTFB);
            }

            if (!HasUserMeetRequirements(Ad, FbUser))
            {
                return(L1.NOTMEETREQUIREMENTS);
            }

            var userLikes = User.FbLikesToday;
            var maxLikes  = User.Membership.MaxFacebookLikesPerDay;
            if (userLikes >= maxLikes)
            {
                return(string.Format(U6004.REACHEDMAXLIKESPERDAY, maxLikes));
            }

            HttpContext.Current.Session["fbcookie"] = "notok";

            if (credit)
            {
                Ad.Click();
                succMsg = U3501.YOUHAVEBEENCREDITED + " (" + AppSettings.Facebook.PointsPerLike + " " + AppSettings.PointsName + ")";
            }
            else
            {
                Ad.Unclick();
                succMsg = string.Format(U5008.POINTSREVERSED, AppSettings.Facebook.PointsPerLike + " " + AppSettings.PointsName);
            }

            if (Ad.ShouldBeFinished)
            {
                Ad.Status = AdvertStatus.Finished;
            }

            Ad.SaveClicks();
            Ad.Save();

            //Use Crediter
            FacebookCrediter Crediter = (FacebookCrediter)CrediterFactory.Acquire(User, CreditType.FacebookLike);
            Crediter.CreditMember(Ad, credit);

            NotificationManager.RefreshWithMember(NotificationType.NewFacebookAds, User);
            return(succMsg);
        }
        else
        {
            return(U5008.MUSTCONNECTFB);
        }
    }