function create_new_user($login, &$err) { $err = ""; $name = clearText($_REQUEST["loginform"]["name"]); if (!strlen($name)) { $err = "Укажите имя"; return false; } $tel = clearText($_REQUEST["loginform"]["tel"]); $city = clearText($_REQUEST["loginform"]["city"]); $cont = clearText($_REQUEST["loginform"]["cont"]); $liketel = intval(clearText(@$_REQUEST["loginform"]["liketel"])); $teltime = clearText(@$_REQUEST["loginform"]["teltime"]); $filial_domain = clearText(@$_REQUEST['loginform']['zf_filial_domain']); //get filial by domain $add_to_filial = Filials::search($filial_domain, $city); // create client $pwd = generate_pasw(5); $client_id = Client::create(array('filial_id' => $add_to_filial, 'fio' => $name, 'email' => $login, 'telnum' => $tel, 'city' => $city, 'liketel' => $liketel, 'teltime' => $teltime, 'contacts' => $cont, 'password' => $pwd)); if ($client_id < 1) { return false; } auth_client($login); // send reg email $txt = "<p>Здравствуйте, " . $name . "!</p>" . "<p>Мы очень рады, что Вы решили воспользоваться нашими услугами и высоко ценим Ваше доверие!</p>" . "<p>Теперь Вы можете войти в личный кабинет:<br>" . " Логин: " . $login . "<br>" . " Пароль: " . $pwd . "<br></p>" . "<p><i>С уважением, компания по написанию студенческих работ.</i></p>"; $email = new Email(); $email->setData(array('email' => $login, 'name' => $name), "Регистрация на сайте написания рефератов", $txt, array(), true, array(), array('email' => Filials::getEmail($add_to_filial), 'name' => Filials::getName($add_to_filial))); if (!$email->send()) { die; } return true; }
function addclient_exec($Frm, $Err) { if (!$Err) { $rnd_pwd = $Frm->GetNmValueI('random_password'); if ($rnd_pwd) { $pwd = generate_pasw(5); } else { $pwd = $Frm->GetNmValueH('password'); } $eml = trim(strtolower($Frm->GetNmValue('email'))); if (Client::exist($eml)) { $Frm->_gui->informer->ERR("Клиент с таким email уже существует"); page_reloadAll(); } $filial_id = Filials::check($Frm->GetNmValueI('filial_id')); $client_id = Client::create(array('filial_id' => $filial_id, 'fio' => $Frm->GetNmValueH('name'), 'email' => $eml, 'telnum' => $Frm->GetNmValueH('phone'), 'city' => $Frm->GetNmValueH('city'), 'icq' => $Frm->GetNmValueH('icq'), 'skype' => $Frm->GetNmValueH('skype'), 'contacts' => $Frm->GetNmValueH('contacts'), 'about' => $Frm->GetNmValueH('about'), 'ref_id' => $Frm->GetNmValueI('ref'), 'from_id' => $Frm->GetNmValueI('client_from'), 'added_by' => $_SESSION["user"]["data"]["id"], 'password' => $pwd)); $Frm->_gui->OK("Добавлено"); switch ($Frm->GetNmValueI('next')) { case 0: page_reloadSec(); break; case 1: header("location: ?section=kln&subsection=2&edit=" . $client_id); die; break; case 2: header("location: ?section=ord&subsection=1&kln_id=" . $client_id); die; break; } } }
function add_client_if_need($orderform = 0) { if (is_client_logged()) { return $_SESSION["frame"]["client"]["id"]; } $add_to_filial = Filials::search($_SESSION['zf_filial_domain'], $_SESSION["zf_user_city"]); $referrer_id = 0; if (!empty($_SESSION['zf_referrer_code'])) { $referrer = Client::findOneBy(array('referrer_code' => $_SESSION['zf_referrer_code'])); if (!empty($referrer)) { $referrer_id = $referrer['id']; } } $pwd = generate_pasw(5); $id = Client::create(array('filial_id' => $add_to_filial, 'fio' => $_SESSION["zf_user_name"], 'email' => $_SESSION["zf_user_login"], 'telnum' => $_SESSION["zf_user_tel"], 'city' => $_SESSION["zf_user_city"], 'password' => $pwd, 'orderform' => $orderform, 'ref_id' => $referrer_id)); auth_client($_SESSION["zf_user_login"]); $_SESSION["new_klient_added"] = true; return $id; }
public static function add_client($client_params) { $result = array('status' => false, 'msg' => ''); if (empty($client_params['fio'])) { $client_params['fio'] = 'Клиент с сайта'; } if (Client::exist($client_params['email'])) { $result['msg'] = "Клиент с email - " . $client_params['email'] . " уже существует"; return $result; } $date = mktime(); if (!empty($client_params['filial_id'])) { $filial_id = Filials::check($client_params['filial_id']); } else { $filial_id = Filials::search($client_params['filial']); if ((!$filial_id || $filial_id == 9) && !empty($client_params['city'])) { $query = "SELECT ftc.filial_id FROM " . TBL_PREF . "data_city dc JOIN " . TBL_PREF . "filial_to_city ftc ON ftc.city_id = dc.id" . " WHERE dc.name = '" . db::input($client_params['city']) . "'"; $filial_id = db::get_single_value($query); if (!$filial_id) { $filial_id = 9; } } } $client_id = Client::create(array('filial_id' => $filial_id, 'fio' => $client_params['fio'], 'email' => $client_params['email'], 'telnum' => $client_params['telnum'], 'city' => $client_params['city'], 'liketel' => $client_params['liketel'], 'teltime' => $client_params['teltime'], 'icq' => $client_params['icq'], 'skype' => $client_params['skype'], 'contacts' => $client_params['contacts'], 'blocked' => $client_params['blocked'], 'about' => $client_params['about'], 'ocenka' => $client_params['ocenka'], 'ref_id' => $client_params['ref_id'], 'from_id' => $client_params['from_id'], 'added_by' => $client_params['added_by'], 'orderform' => $client_params['orderform'], 'password' => $client_params['password'])); return self::generate_response(true, "OK", array('id' => $client_id, 'date' => $date)); }