Current Path : /home/bitrix/ext_www/dev.klimatlend.ua/personal/profile/ |
Current File : /home/bitrix/ext_www/dev.klimatlend.ua/personal/profile/ajax.php |
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");?> <? if(isset($_GET["USER_PASSWORD"]) && isset($_GET["USER_PASSWORD_CONFIRM"]) && isset($_GET["USER_STREET"]) && isset($_GET["USER_MOBILE"]) && isset($_GET["WORK_POSITION"]) && isset($_GET["WORK_COMPANY"]) && isset($_GET["EMAIL"]) && isset($_GET["FIO"]) ){ global $USER; $userID = $USER->GetID(); if($userID){ $NAME = explode(" ", htmlspecialchars($_GET["FIO"])); $EMAIL = htmlspecialchars($_GET["EMAIL"]); $PASSWORD = addslashes($_GET["USER_PASSWORD"]); $REPASSWORD = addslashes($_GET["USER_PASSWORD_CONFIRM"]); $PERSONAL_STREET = htmlspecialchars($_GET["USER_STREET"]); $PERSONAL_MOBILE = htmlspecialchars($_GET["USER_MOBILE"]); $PERSONAL_PROFESSION = htmlspecialchars($_GET["WORK_POSITION"]); $PERSONAL_WWW = htmlspecialchars($_GET["WORK_COMPANY"]); $user = new CUser; $fields = Array( "NAME" => BX_UTF === true ? $NAME[1] : iconv("UTF-8","windows-1251//IGNORE", $NAME[1]), "LAST_NAME" => BX_UTF === true ? $NAME[0] : iconv("UTF-8","windows-1251//IGNORE", $NAME[0]), "SECOND_NAME" => BX_UTF === true ? $NAME[2] : iconv("UTF-8","windows-1251//IGNORE", $NAME[2]), "PERSONAL_STREET" => BX_UTF === true ? $PERSONAL_STREET : iconv("UTF-8","windows-1251//IGNORE", $PERSONAL_STREET), "WORK_POSITION" => BX_UTF === true ? $PERSONAL_PROFESSION : iconv("UTF-8","windows-1251//IGNORE", $PERSONAL_PROFESSION), "WORK_COMPANY" => BX_UTF === true ? $PERSONAL_WWW : iconv("UTF-8","windows-1251//IGNORE", $PERSONAL_WWW), "PERSONAL_MOBILE" => BX_UTF === true ? $PERSONAL_MOBILE : iconv("UTF-8","windows-1251//IGNORE", $PERSONAL_MOBILE), "EMAIL" => $EMAIL, "PASSWORD" => $PASSWORD, "CONFIRM_PASSWORD" => $REPASSWORD ); if(empty($PASSWORD)){ unset($fields["PASSWORD"]); unset($fields["REPASSWORD"]); } if(!$user->Update($userID, $fields)){ $result = array( "message" => strip_tags($user->LAST_ERROR), "class" => "errortext", "reload" => false ); }else{ $result = array( "message" => "Информация успешно сохранена", "class" => "success", "reload" => true ); } }else{ $result = array( "message" => "Требуется авторизация", "class" => "errortext", "reload" => false ); } }else{ $result = array( "message" => "Ошибка передачи формы", "class" => "errortext", "reload" => false ); } echo jsonEn($result); function jsonEn($data){ foreach ($data as $index => $arValue) { $arJsn[] = '"'.$index.'" : "'.addslashes($arValue).'"'; } return "{".implode($arJsn, ",")."}"; } ?>