require_once _SERVER DOCUMENT_ROOT bitrix modules main include prolog_

  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
<?
require_once $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php";
if(trim($_REQUEST["name"]) == "") {
$error[]=Array(
"fail"=>"name",
"error"=>"Заполните имя"
);
}
if(trim($_REQUEST["mail"]) == "") {
$error[]=Array(
"fail"=>"mail",
"error"=>"Заполните E-mail"
);
}
if($_REQUEST["password"]=="") {
$error[]=Array(
"fail"=>"password",
"error"=>"Придумайте пароль"
);
}
if($_REQUEST["retry_password"]=="") {
$error[]=Array(
"fail"=>"retry_password",
"error"=>"Повторите пароль"
);
}
if(($_REQUEST["password"]!="")and($_REQUEST["password"]!=$_REQUEST["retry_password"])){
$error[]=Array(
"fail"=>"password",
"error"=>"Пароли не совпадают"
);
}
if((strlen($_REQUEST["password"]) < 6) && (strlen($_REQUEST["password"]) != 0)){
$error[]=Array(
"fail"=>"password",
"error"=>"Слишком короткий пароль. <br> Минимальная длина пароля - 6 символов."
);
}
if(($_REQUEST["mail"]!="")and(!(check_email($_REQUEST["mail"])))) {
$error[]=Array(
"fail"=>"mail",
"error"=>"Некорректный e-mail"
);
}
if($_REQUEST["mail"]!=""){
$rsUsers = CUser::GetList(($by="ID"), ($order="ASC"), Array("ACTIVE"=>"Y","EMAIL"=>$_REQUEST["mail"]));
if($rsUsers->NavNext(true, "f_")) {
$error[]=Array(
"fail"=>"error",
"error"=>"Пользователь с указанным e-mail уже существует"
);
}
}
if((count($error)>0)){
print json_encode(array(
"errors" => $error
));
}
else{
$bConfirmReq = COption::GetOptionString("main", "new_user_registration_email_confirmation", "N") == "Y";
$user = new CUser;
$arFields = Array(
"NAME" => $_REQUEST["name"],
"EMAIL" => $_REQUEST["mail"],
"LOGIN" => $_REQUEST["mail"],
"PASSWORD" => $_REQUEST["password"],
"CONFIRM_PASSWORD" => $_REQUEST["password"],
"LID" => SITE_ID,
"ACTIVE" => $bConfirmReq? "N": "Y",
"CONFIRM_CODE" => $bConfirmReq? randString(8): "",
"GROUP_ID" => array(5)
);
$ID = $user->Add($arFields);
if (intval($ID) > 0){
// USER_ID# - ID пользователя
// LOGIN# - Логин
// EMAIL# - EMail
// NAME# - Имя
// LAST_NAME# - Фамилия
// USER_IP# - IP пользователя
// USER_HOST# - Хост пользователя
// CONFIRM_CODE# - Код подтверждения
$event = new CEvent;
// $event->SendImmediate("NEW_USER", SITE_ID, $arEventFields);
if($bConfirmReq){
$arEventFields = array(
"USER_ID" => $ID,
"LOGIN" => $arFields["LOGIN"],
"EMAIL" => $arFields["EMAIL"],
"NAME" => $arFields["NAME"],
"LAST_NAME" => $arFields["LAST_NAME"],
"CONFIRM_CODE" => $arFields["CONFIRM_CODE"]
);
//$event->SendImmediate("NEW_USER_CONFIRM", SITE_ID, $arEventFields);
$event->Send("NEW_USER_CONFIRM", SITE_ID, $arEventFields);
}
//echo "Пользователь успешно добавлен.";
}
// else
// echo $user->LAST_ERROR;
print json_encode(array());
}
//Почтовые события
?>