/
Register.aspx.cs
1254 lines (1086 loc) · 56.9 KB
/
Register.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ASPnetDating
* Copyright (C) 2003-2010 eStream
* lovehitch.com
*
* IMPORTANT: This is a commercial software product. By using this product
* you agree to be bound by the terms of the ASPnetDating license agreement.
* It can be found at lovehitch.com/agreement.htm
*
* This notice may not be removed from the source code.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IdentityModel.Claims;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;
using AspNetDating.Classes;
using AspNetDating.Classes.MySpace;
using AspNetDating.Components;
using Facebook;
using Microsoft.IdentityModel.TokenProcessor;
using Photo = AspNetDating.Classes.Photo;
namespace AspNetDating
{
public partial class Register : PageBase
{
protected DatePicker datePicker1, datePicker2;
protected DropDownList dropCity;
protected MultiView multiViewButtons;
protected View view1, view2;
protected LargeBoxStart LargeBoxStart1;
//public string pleaseChooseTranslated = "--- " + Lang.Translate("please choose") + " ---";
private string MySpaceID
{
get
{
return ViewState["MySpaceID"] as string;
}
set
{
ViewState["MySpaceID"] = value;
}
}
private long? FacebookID
{
get
{
return ViewState["FacebookID"] as long?;
}
set
{
ViewState["FacebookID"] = value;
}
}
private string PrimaryPhotoURL
{
get
{
return Session["PrimaryPhotoURL"] as string;
}
set
{
Session["PrimaryPhotoURL"] = value;
}
}
private long[] FacebookFriendIDs
{
get
{
return ViewState["FacebookFriendIDs"] as long[];
}
set
{
ViewState["FacebookFriendIDs"] = value;
}
}
private string[] FriendIDs
{
get
{
return ViewState["FriendIDs"] as string[];
}
set
{
ViewState["FriendIDs"] = value;
}
}
public Register()
{
RequiresAuthorization = false;
}
protected void Page_Load(object sender, EventArgs e)
{
Session["IsRegistrationFormValidated"] = null;
if (CurrentUserSession != null
&& CurrentUserSession.IsAuthorized)
{
Response.Redirect(MatchmakerHelper.CurrentHomePage);
}
asyncImageUpload.UploadedComplete += new EventHandler<AsyncFileUploadEventArgs>(asyncImageUpload_UploadedComplete);
//if (!Page.ClientScript.IsStartupScriptRegistered(Page.GetType(),"newscript"))
//{
// var sb = new StringBuilder();
// sb.Append("$('.reg_ddl').hover(function() { alert('play mm'); });");
// sb.Append("$('img').hover(function() { alert('right'); });");
// Page.ClientScript.RegisterStartupScript(Page.GetType(), "newscript", sb.ToString(), true);
//}
if (!Page.IsPostBack)
{
PrepareStrings();
if (Request.Params["token"] == "1")
LoadTokenData();
string fbParamVal = Request.QueryString["facebook"];
if (Config.Misc.EnableMySpaceIntegration &&
!String.IsNullOrEmpty(Context.Request.QueryString["myspace"]))
PopulateUserDataUsingMySpace();
var referrer = Context.Request.UrlReferrer;
if (Config.Misc.EnableFacebookIntegration &&
((referrer != null && (referrer.Query.Contains("facebook=1") ||
referrer.AbsolutePath.ToLower().Contains("facebook")))
|| (fbParamVal.IsNotNullOrEmpty() && int.Parse(fbParamVal) == 1)))
{
if (!String.IsNullOrEmpty(Context.Request.QueryString["login"]))
divLogin.Visible = true;
PopulateUserDataUsingFacebook();
if (FacebookHelper.IsCurrentSessionConnected)
{
trUsername.Visible = false;
trPassword1.Visible = false;
trPassword2.Visible = false;
trCaptcha.Visible = false;
}
}
}
}
private void LoadTokenData()
{
Token token = Session["Token"] as Token;
if (token == null) return;
if (Classes.User.GetUsernameByTokenUniqueId(token.UniqueID) != null)
{
ResponseEndWithErrorMessage("The presented information card is already used for another account!");
return;
}
CascadingDropDownCountry.SelectedValue = token.Claims[ClaimTypes.Country];
CascadingDropDownState.SelectedValue = token.Claims[ClaimTypes.StateOrProvince];
CascadingDropDownCity.SelectedValue = token.Claims[ClaimTypes.Locality];
//txtZipCode.Text = token.Claims[ClaimTypes.PostalCode];
txtName.Text = token.Claims[ClaimTypes.GivenName] + " " + token.Claims[ClaimTypes.Surname];
dropGender.SelectedValue = ((int)Enum.Parse(typeof(User.eGender), token.Claims[ClaimTypes.Gender])).ToString();
//dropStatus.SelectedValue = ((int)Enum.Parse(typeof(User.eGender), token.Claims[ClaimTypes.Gender])).ToString();
BirthdayPicker1.CurrentText = token.Claims[ClaimTypes.DateOfBirth];
//txtDatePicker.Text = token.Claims[ClaimTypes.DateOfBirth];
datePicker1.SelectedDate = BirthdayPicker1.SelectedDate;
txtEmail.Text = token.Claims[ClaimTypes.Email];
ViewState["TokenUniqueId"] = token.UniqueID;
divCardSpace.Visible = false;
}
private void PrepareStrings()
{
LargeBoxStart1.Title = Lang.Trans("Registration details");
if (Config.Users.LocationPanelVisible)
ShowLocation();
else
HideLocation();
CascadingDropDownCountry.PromptText = PleaseChooseTranslated;
CascadingDropDownState.PromptText = PleaseChooseTranslated;
CascadingDropDownCity.PromptText = PleaseChooseTranslated;
lblUsername.Text = Lang.Trans("Username");
lblEmail.Text = Lang.Trans("E-Mail");
lblPassword.Text = Lang.Trans("Password");
lblPassword2.Text = Lang.Trans("Confirm password");
lblName.Text = Lang.Trans("Full name");
lblGender.Text = Lang.Trans("Gender");
lblBirthdate.Text = Lang.Trans("Birth date");
lblInterestedIn.Text = Lang.Trans("Interested in");
lblInvitationCode.Text = Lang.Trans("Invitation Code");
btnLogin.Text = Lang.Trans("Login");
lblPhoto.Text = Lang.Trans("Primary Photo");
cbAgreement.Text = Lang.Trans("I have read and accept the ") +
"<span><a href='Agreement.aspx' target='_new'>" +
Lang.Trans("terms & conditions") + "</a> </span><span>" +
Lang.Trans(" and the ") + "</span><span><a href='Privacy.aspx' target='_new'>" +
Lang.Trans("privacy policy") + "</a></span>"
;
dropGender.Items.Add(
new ListItem(Lang.Trans("Female"), ((int)Classes.User.eGender.Female).ToString()));
dropGender.Items.Add(
new ListItem(Lang.Trans("Male"), ((int)Classes.User.eGender.Male).ToString()));
if (Config.Users.CouplesSupport)
{
dropGender.Items.Add(
new ListItem(Lang.Trans("Couple"), ((int)Classes.User.eGender.Couple).ToString()));
}
if (true)
{//Config.Users.InterestedInFieldEnabled) {
trInterestedIn.Visible = true;
//dropInterestedIn.Items.Add(
// new ListItem(Lang.Trans("All"), ((int)Classes.User.eGenderSearch.All).ToString()));
dropInterestedIn.Items.Add(
new ListItem(Lang.Trans("Male"), ((int)Classes.User.eGender.Male).ToString()));
dropInterestedIn.Items.Add(
new ListItem(Lang.Trans("Female"), ((int)Classes.User.eGender.Female).ToString()));
if (Config.Users.CouplesSupport)
{
dropInterestedIn.Items.Add(
new ListItem(Lang.Trans("Couple"), ((int)Classes.User.eGender.Couple).ToString()));
}
dropInterestedIn.Items.Add(
new ListItem(Lang.Trans("Matchmaking"), ((int)Classes.User.eGender.Matchmaker).ToString()));
if (Config.Users.DisableGenderInformation)
dropInterestedIn.SelectedValue = ((int)Classes.User.eGenderSearch.All).ToString();
}
else trInterestedIn.Visible = false;
if (Config.Users.InvitationCode == String.Empty)
trInvitationCode.Visible = false;
if (Config.Misc.EnableCaptcha && !FacebookHelper.IsCurrentSessionConnected)
{
lblCaptcha.Text = Lang.Trans("Enter the code shown above");
lblAntiSpam.Text = Lang.Trans("Spam protection");
trCaptcha.Visible = true;
}
pnlGender.Visible = !Config.Users.DisableGenderInformation;
pnlBirthdate.Visible = !Config.Users.DisableAgeInformation;
if (Config.Users.DisableAgeInformation)
{
datePicker1.SelectedDate = new DateTime(DateTime.Now.Year - Config.Users.MinAge, 1, 1);
//txtDatePicker.Text = datePicker1.SelectedDate.ToString();
BirthdayPicker1.CurrentText = datePicker1.SelectedDate.ToString();
}
divCardSpace.Visible = Config.Users.EnableCardSpace;
divMySpace.Visible = Config.Misc.EnableMySpaceIntegration;
if (Config.Misc.EnableMySpaceIntegration)
btnUseMySpace.AlternateText = Lang.Trans("Import from MySpace");
divFacebook.Visible = Config.Misc.EnableFacebookIntegration;
btnRegister.Text = Lang.Trans("Register") + " » ";
}
#region Web Form Designer generated code
protected override void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
public string LastAsyncFileUploadLocation
{
get { return (string)Session["LastAsyncFileUploadLocation"] ?? "Images/default_male.png"; }
set { Session["LastAsyncFileUploadLocation"] = value ?? "Images/default_male.png"; }
}
void asyncImageUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
{
string fileRelativeLocation = "/AsyncFileUpload/Uploads/" +
Path.GetFileName(e.FileName);
string LastAsyncFileUploadLocation = MapPath("~" + fileRelativeLocation);
if (File.Exists(LastAsyncFileUploadLocation))
File.Delete(LastAsyncFileUploadLocation);
asyncImageUpload.SaveAs(LastAsyncFileUploadLocation);
PrimaryPhotoURL = Config.Urls.Home + fileRelativeLocation;
}
protected void asyncUploadPhoto_OnClientUploadCompleted(object sender, EventArgs e)
{
//Response.BinaryWrite(asyncImageUpload.FileBytes);
}
protected void ResponseEndWithErrorMessage(string message)
{
lblError.Text = Lang.Trans(message);
lblError.Focus();
this.UpdatePanelRegister.Update();
}
protected void btnRegister_Click(object sender, EventArgs e)
{
if (!FacebookHelper.IsCurrentSessionConnected)
{
#region Validate username
Session["IsRegistrationFormValidated"] = false;
try
{
if (txtUsername.Text.Length < 6)
{
ResponseEndWithErrorMessage("Please specify username, at list 6 alphanumeric characters!");
return;
}
if (Classes.User.IsUsernameTaken(txtUsername.Text))
{
ResponseEndWithErrorMessage("Username is already taken!");
return;
}
foreach (string reservedUsername in Config.Users.ReservedUsernames)
{
if (reservedUsername == txtUsername.Text.ToLower())
{
ResponseEndWithErrorMessage("Username is reserved!");
return;
}
}
}
catch (ArgumentException err) // Invalid username
{
ResponseEndWithErrorMessage(err.Message);
return;
}
#endregion
#region Validate passwords
if (txtPassword.Text.Length < 6)
{
ResponseEndWithErrorMessage("Please specify password, at leaset 6 alphanumeric characters!");
return;
}
if (txtPassword2.Text.Length == 0)
{
ResponseEndWithErrorMessage("Please verify password!");
return;
}
if (txtPassword.Text != txtPassword2.Text)
{
ResponseEndWithErrorMessage("Passwords do not match!");
return;
}
#endregion
#region Validate captcha
if (Config.Misc.EnableCaptcha &&
(Session["Captcha_RandomCode"] == null || (string)Session["Captcha_RandomCode"] != txtCaptcha.Text))
{
ResponseEndWithErrorMessage("Invalid verification code!");
return;
}
#endregion
}
else
{
txtUsername.Text = FacebookHelper.CurrentSessionUserID.ToString();
}
#region Validate e-mail address
try
{
if (txtEmail.Text.Length == 0)
{
ResponseEndWithErrorMessage("Please specify e-mail address!");
return;
}
if (txtEmail.Text.ToLower().EndsWith("@mail.bg"))
{
ResponseEndWithErrorMessage("E-mails from mail.bg are not accepted!");
return;
}
if (Config.Users.CheckForDuplicateEmails && Classes.User.IsEmailUsed(txtEmail.Text))
{
ResponseEndWithErrorMessage("E-mail address is already used!");
return;
}
}
catch (ArgumentException err) // Invalid e-mail address
{
ResponseEndWithErrorMessage(err.Message);
return;
}
#endregion
#region Validate name
if (txtName.Text.Length == 0)
{
ResponseEndWithErrorMessage("Please enter your name!");
return;
}
#endregion
#region Validate gender
if (dropGender.SelectedIndex < 0)
{
ResponseEndWithErrorMessage("Please select your gender!");
return;
}
#endregion
#region Validate InterestedIn
if (Config.Users.InterestedInFieldEnabled)
{
if (dropInterestedIn.SelectedIndex < 0)
{
ResponseEndWithErrorMessage("Please select who are you interested in!");
return;
}
}
#endregion
#region Validate birthdate1
//IFormatProvider culture = new CultureInfo("he-IL", true);
//string dateFormat = "dd/MM/yyyy";
//DateTime parsedDate;
//if (DateTime.TryParseExact(txtDatePicker.Text, dateFormat, culture, DateTimeStyles.None, out parsedDate))
// datePicker1.SelectedDate = parsedDate;
datePicker1.SelectedDate = BirthdayPicker1.SelectedDate;
if (!datePicker1.ValidDateEntered)
{
ResponseEndWithErrorMessage("Please select valid birthdate!");
return;
}
#endregion
//#region Validate birthdate2
//if((User.eGender)Convert.ToInt32(dropGender.SelectedValue) == Classes.User.eGender.Couple
// && !datePicker2.ValidDateEntered)
//{
// lblError.Text = Lang.Trans("Please select valid birthdate") + "!";
// return;
//}
//#endregion
#region Validate agreement
if (!cbAgreement.Checked)
{
ResponseEndWithErrorMessage("You must accept the agreement to proceed!");
return;
}
#endregion
#region Validate location
if (Config.Users.LocationPanelVisible)
{
if (dropCountry != null && dropCountry.SelectedValue == String.Empty)
{
ResponseEndWithErrorMessage("Please select your country!");
return;
}
//if (txtZipCode != null && txtZipCode.Text == String.Empty)
//{
// lblError.Text = Lang.Trans("Please enter your Zip/Postal Code");
// return;
//}
//ifA B VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV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VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV(dropRegion.Items.Count >= 1 && dropRegion.SelectedValue == "") {
// ResponseEndWithErrorMessage("Please select your state!");
// return;
//}
//if(dropCity != null && dropCity.SelectedValue == "") {
// ResponseEndWithErrorMessage("Please select your city!");
// return;
//}
}
#endregion
#region Validate Invitation Code
if (Config.Users.InvitationCode != String.Empty)
{
if (Config.Users.InvitationCode != txtInvitationCode.Text)
{
ResponseEndWithErrorMessage("Invalid Invitation Code!");
return;
}
}
#endregion
#region Validate IP address
if (Properties.Settings.Default.BannedCountries.Count > 0)
{
foreach (string countryCode in Properties.Settings.Default.BannedCountries)
{
if (IPToCountry.GetCountry(Request.UserHostAddress) == countryCode.Trim())
{
ResponseEndWithErrorMessage("Registration is not allowed for your country!");
return;
}
}
}
#endregion
Session["IsRegistrationFormValidated"] = true;
var postRegistrationPopup = @"<div class='PostRegistrationPopupBg' >
<table border='0' cellpadding='0' cellspacing='0' width='100%'>
<tr style='height:40px;width:100%;'>
<td></td>
</tr>
<tr style='height:30px;width:100%;'>
<td></td>
</tr>
<tr style='height:55px;width:100%;'>
<td>
<div class='fl' style='width:220px;height:50px;margin-left:40px;cursor:pointer;'
onclick=""window.location='ManageProfile.aspx'""></div>
<div class='fl' style='width:200px;height:50px;margin-left:20px;cursor:pointer;'
onclick=""window.location='Home.aspx'""></div>
</td>
</tr>
<tr style='height:30px;width:100%;'>
<td></td>
</tr>
</table>
</div>";
//postRegistrationPopup = "";
try
{
User newUser = new User(txtUsername.Text);
#region Save location
if (Config.Users.LocationPanelVisible)
{
if (dropCountry != null)
{
newUser.Country = dropCountry.SelectedValue;
}
if (dropRegion != null)
{
newUser.State = dropRegion.SelectedValue;
}
//if (txtZipCode != null)
//{
// newUser.ZipCode = txtZipCode.Text;
//}
if (dropCity != null)
{
newUser.City = dropCity.SelectedValue;
}
Location loc = Config.Users.GetLocation(newUser.Country, newUser.State, newUser.City);
if (loc != null)
{
newUser.Longitude = loc.Longitude;
newUser.Latitude = loc.Latitude;
}
}
#endregion
newUser.Email = txtEmail.Text;
newUser.Name = txtName.Text;
var pass = (-DateTime.Now.Ticks).ToString();
if (pass.Length > 20) pass = pass.Substring(0, 20);
newUser.Password = FacebookHelper.IsCurrentSessionConnected
? pass : txtPassword.Text;
newUser.Gender = (User.eGender)Convert.ToInt32(dropGender.SelectedValue);
datePicker1.SelectedDate = BirthdayPicker1.SelectedDate;// DateTime.Parse(txtDatePicker.Text);
newUser.Birthdate = datePicker1.SelectedDate;
newUser.LanguageId = LanguageId;
if (newUser.Gender == Classes.User.eGender.Couple)
{
newUser.Birthdate2 = datePicker2.SelectedDate;
}
if (Config.Users.InterestedInFieldEnabled)
{
newUser.InterestedIn = (User.eGender)Convert.ToInt32(dropInterestedIn.SelectedValue);
}
else
{
if (Config.Users.DisableGenderInformation)
newUser.InterestedIn = Classes.User.eGender.Male;
else
newUser.InterestedIn = newUser.Gender == Classes.User.eGender.Male
? Classes.User.eGender.Female
: Classes.User.eGender.Male;
}
newUser.ReceiveEmails = Config.Users.EmailNotificationsDefault;
if (ViewState["TokenUniqueId"] is string)
newUser.TokenUniqueId = (string)ViewState["TokenUniqueId"];
#region Set and Delete invitedBy cookie
if (Request.Cookies["invitedBy"] != null)
{
newUser.InvitedBy = Server.HtmlEncode(Request.Cookies["invitedBy"].Value);
HttpCookie cookie = new HttpCookie("invitedBy");
cookie.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(cookie);
}
#endregion
#region Set and Delete affiliateID cookie
if (Request.Cookies["affiliateID"] != null)
{
newUser.AffiliateID = Convert.ToInt32(Server.HtmlEncode(Request.Cookies["affiliateID"].Value));
HttpCookie cookie = new HttpCookie("affiliateID");
cookie.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(cookie);
}
#endregion
if (Config.Misc.EnableMySpaceIntegration)
newUser.MySpaceID = MySpaceID;
if (Config.Misc.EnableFacebookIntegration)
newUser.FacebookID = FacebookID;
newUser.Credits = 181818;
newUser.Create(Request.UserHostAddress);
StorePrimaryPhoto(newUser);
if (File.Exists(LastAsyncFileUploadLocation))
File.Delete(LastAsyncFileUploadLocation);
if (Config.Users.SmsConfirmationRequired)
{
Response.Redirect("SmsConfirm.aspx?username=" + newUser.Username);
return;
}
if (Config.Users.AutoActivateUsers ||
(/*FacebookEmail == txtEmail.Text &&*/ IsFacebookVerified))
{
if (Config.Users.SendWelcomeMessage)
{
Message.SendWelcomeMessage(newUser);
}
//StatusPageMessage = Lang.Trans("<b>Your account has been created successfully!</b><br>" +
// "Please click on the link below to edit your profile.<br><br>");
//NameValueCollection link = new NameValueCollection();
//link.Add(Config.Urls.Home + "/ManageProfile.aspx", Config.Urls.Home + "/ManageProfile.aspx");
//StatusPageLink = link;
//((PageBase)Page).StatusPageLinkSkindId = "";
//((PageBase)Page).StatusPageLinkText = Config.Urls.Home + "/ManageProfile.aspx";
//((PageBase)Page).StatusPageLinkURL = Config.Urls.Home + "/ManageProfile.aspx";
UserSession userSession = null;
try
{
userSession = new UserSession(newUser.Username);
((PageBase)Page).CurrentUserSession = userSession;
MatchmakerHelper.CurrentUsername = userSession.Username;
userSession.Authorize(Session.SessionID);
//if(Config.Misc.EnableMySpaceIntegration ||
if (Config.Misc.EnableFacebookIntegration)
{
FacebookHelper.AddFriends(newUser, 0, HttpContext.Current, null);
}
#region Autojoin to group
Group[] autojoinGroups = Group.Fetch(true);
if (autojoinGroups.Length > 0)
{
var groups =
autojoinGroups.Where(
g => g.Approved &&
(g.AutojoinCountry == null || g.AutojoinCountry == userSession.Country) &&
(g.AutojoinRegion == null || g.AutojoinRegion == userSession.State) &&
(g.AutojoinCity == null || g.AutojoinCity == userSession.City));
foreach (Group group in groups)
{
GroupMember groupMember = new GroupMember(group.ID, userSession.Username);
groupMember.Active = true;
groupMember.Type = GroupMember.eType.Member;
groupMember.Save();
group.ActiveMembers++;
group.Save();
}
}
#endregion
//Response.Redirect("ManageProfile.aspx");
//multiViewButtons.ActiveViewIndex = 1;
//return;
StatusPageMessage = Lang.Trans("<b>Your account has been created successfully!</b><br><br>")
+ postRegistrationPopup;
}
catch (Exception err)
{
StatusPageMessage = err.Message;
}
}
else
StatusPageMessage = Lang.Trans
("<b>Your account has been created successfully!</b><br><br>"
+ "You will receive a confirmation e-mail shortly. In order "
+ "to finish your registration you'll have to click the "
+ "activation link in the e-mail.")
+ postRegistrationPopup;
if (newUser.InterestedIn == Classes.User.eGender.Matchmaker)
Response.Redirect("Home_mm.aspx");
}
catch (System.Threading.ThreadAbortException) { }
catch (ArgumentException err)
{
ResponseEndWithErrorMessage(err.Message);
return;
}
catch (Exception err)
{
ResponseEndWithErrorMessage("Unknown error has occured while trying to create your account! Please try again later.");
Log(err);
return;
}
Response.Redirect("ShowStatus.aspx");
}
protected void cbAgreement_CheckedChanged(object sender, EventArgs e)
{
// txtPassword.Attributes.Add("value", txtPassword.Text);
// txtPassword2.Attributes.Add("value", txtPassword.Text);
//btnRegister. = ((CheckBox) sender).Checked;
}
private void HideLocation()
{
if (trCountry != null)
{
trCountry.Visible = false;
}
if (trState != null)
{
trState.Visible = false;
}
//if (trZipCode != null)
//{
// trZipCode.Visible = false;
//}
if (trCity != null)
{
trCity.Visible = false;
}
}
private void ShowLocation()
{
if (trCountry != null)
{
trCountry.Visible = true;
}
if (trState != null)
{
trState.Visible = true;
}
//if (trZipCode != null)
//{
// trZipCode.Visible = true;
//}
if (trCity != null)
{
trCity.Visible = true;
}
}
protected void btnUseMySpace_Click(object sender, ImageClickEventArgs e)
{
PopulateUserDataUsingMySpace();
}
//protected void UseMySpace_Click(object sender, EventArgs e)
//{
// PopulateUserDataUsingMySpace();
//}
private void StorePrimaryPhoto(User user)
{
if (PrimaryPhotoURL != null)
{
var request = (HttpWebRequest)WebRequest.Create(PrimaryPhotoURL);
request.Method = "GET";
using (var stream = request.GetResponse().GetResponseStream())
{
Photo photo = new Photo();
System.Drawing.Image image;
try
{
image = System.Drawing.Image.FromStream(stream);
photo.Image = image;
photo.Primary = true;
photo.Name = String.Empty;
photo.Description = String.Empty;
photo.User = user;
photo.Save(true);
Photo.SetPrimary(user.Username, photo);
photo.Image.Dispose();
}
catch (Exception ex)
{
Log(ex);
}
}
}
}
public void AddFriends(User user)
{
var usernames = new List<string>();
//TODO: handle my space friends here
//if(FriendIDs != null && FriendIDs.Length > 0) {
// usernames.AddRange(Classes.User.FetchUsernamesByMySpaceID(FriendIDs));
//}
if (FacebookFriendIDs != null && FacebookFriendIDs.Length > 0)
{
var oldUsernames = new List<string>();
oldUsernames.AddRange(Classes.User.FetchUsernamesByFacebookID(FacebookFriendIDs));
var res = new UserSearchResults { Usernames = oldUsernames.ToArray() };
var users = res.Get().ToList();
var friends = FacebookFriendIDs.ToList();
var newUsers =
friends.Where(id => users.Where(u => u.FacebookID == id).FirstOrDefault() == null)
.Select(id => new User(id.ToString())
{
Active = false,
FacebookID = id
});
foreach (var newUser in newUsers)
{
newUser.Create("127.0.0.1");
}
usernames.AddRange(Classes.User.FetchUsernamesByFacebookID(FacebookFriendIDs));
}
user.AddBulkToFacebookIdFriends(usernames.ToArray());
foreach (var username in usernames)
{
try
{
User friend = Classes.User.Load(username);
friend.AddToFriends(user.Username);
}
catch (NotFoundException)
{
}
}
}
private void PopulateUserDataUsingMySpace()
{
UserData userData = null;
Uri uri = Context.Request.Url;
if (Context.Request.QueryString["myspace"] == null)
uri = new Uri(uri + "?myspace=1");
try
{
userData = DataAvailability.GetUserData(Context, uri);
}
catch (AuthorizationRequiredException authex)
{
Response.Redirect(authex.AuthorizationUri.AbsoluteUri);
}
catch (OAuth.Net.Common.OAuthRequestException)
{
DataAvailability.RevokeAccess(Context);
Response.Redirect("Register.aspx?myspace=1");
}
if (userData != null)
{
if (!String.IsNullOrEmpty(userData.PrimaryEmail))
txtEmail.Text = userData.PrimaryEmail;
if (userData.Name != null)
{
if (!String.IsNullOrEmpty(userData.Name.GivenName))
txtName.Text = userData.Name.GivenName;
if (!String.IsNullOrEmpty(userData.Name.FamilyName))
txtName.Text += " " + userData.Name.FamilyName;
}
if (!String.IsNullOrEmpty(userData.NickName))
txtUsername.Text = userData.NickName;
if (userData.Gender.HasValue)
{
dropGender.SelectedValue = ((int)userData.Gender).ToString();
switch (userData.Gender)
{
case Classes.User.eGender.Male:
dropInterestedIn.SelectedValue = ((int)Classes.User.eGender.Female).ToString();
break;
case Classes.User.eGender.Female:
dropInterestedIn.SelectedValue = ((int)Classes.User.eGender.Male).ToString();
break;
}
}
if (userData.DateOfBirth.HasValue)
{
datePicker1.SelectedDate = userData.DateOfBirth.Value;
//txtDatePicker.Text = datePicker1.SelectedDate.ToString();
BirthdayPicker1.CurrentText = datePicker1.SelectedDate.ToString();
}
string primaryPhotoURL = userData.PrimaryPhotoURL;
if (primaryPhotoURL != null && !primaryPhotoURL.Contains("no_pic"))
PrimaryPhotoURL = primaryPhotoURL;
MySpaceID = userData.ID;
#region get friends
string[] friendIDs = null;
try
{
friendIDs = DataAvailability.GetFriends(Context, uri);
}
catch (AuthorizationRequiredException authex)
{
Response.Redirect(authex.AuthorizationUri.AbsoluteUri);
}
if (friendIDs != null && friendIDs.Length > 0)