Ejemplo n.º 1
0
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>" . "&nbsp;Логин: " . $login . "<br>" . "&nbsp;Пароль: " . $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;
}
Ejemplo n.º 2
0
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;
        }
    }
}
Ejemplo n.º 3
0
 public static function create(array $data)
 {
     if (empty($data) || !is_array($data) || empty($data['email']) || empty($data['password']) || self::exist($data['email'])) {
         return false;
     }
     $data['email'] = trim($data['email']);
     $default_parameters = array('filial_id' => 0, 'fio' => '', 'hpwd' => md5($data['password'] . strtolower($data['email'])), 'telnum' => '', 'cont' => '', 'group_id' => 0, 'comments' => '', 'payment_requisites' => '');
     $data = array_merge($default_parameters, $data);
     $data['filial_id'] = Filials::check($data['filial_id']);
     return parent::create($data);
 }
Ejemplo n.º 4
0
 public static function create(array $data)
 {
     if (empty($data) || !is_array($data) || empty($data['email'])) {
         return false;
     }
     if (!empty($data['password'])) {
         $password = $data['password'];
     } else {
         $password = generate_pasw(5);
     }
     $default_parameters = array('filial_id' => 0, 'password' => $password, 'hpwd' => md5($password . strtolower($data['email'])), 'fio' => '', 'liketel' => 0, 'teltime' => '', 'icq' => '', 'skype' => '', 'contacts' => '', 'regdate' => time(), 'blocked' => 0, 'about' => '', 'ocenka' => 0, 'ref_id' => 0, 'from_id' => 0, 'added_by' => 0, 'orderform' => 0, 'referrer_code' => uniqid());
     $data = array_merge($default_parameters, $data);
     if (self::exist($data['email'])) {
         return false;
     }
     $data['filial_id'] = Filials::check($data['filial_id']);
     return parent::create($data);
 }
Ejemplo n.º 5
0
function check_rm_form(&$err)
{
    if (isset($_REQUEST["ok"])) {
        return true;
    }
    $err = "";
    if (!isset($_REQUEST["rm_user_login"]) || !strlen($_REQUEST["rm_user_login"])) {
        return false;
    }
    if (!isset($_REQUEST["rm_user_code"])) {
        return false;
    }
    $login = clearText($_REQUEST["rm_user_login"]);
    $code = clearText($_REQUEST["rm_user_code"]);
    if (!strlen($login)) {
        $err = "Укажите адрес электронной почты";
        return false;
    }
    if (!validateEmail($login)) {
        $err = "Укажите корректный адрес электронной почты";
        return false;
    }
    if (strlen($code) != 4 || $code != @$_SESSION["remind_scode"]) {
        $err = "Неверный код";
        return false;
    }
    $client = Client::findOneBy(array('email' => $login));
    if ($client) {
        $txt = "<p>Здравствуйте, " . $client["fio"] . "!</p>";
        $txt .= "Пароль для доступа к личному кабинету: <i>" . $client["password"] . "</i>";
        $txt .= "<p><i>С уважением, компания по написанию студенческих работ.</i></p>";
        $email = new Email();
        $email->setData(array('email' => $client["email"], 'name' => $client["fio"]), "Восстановление пароля", $txt, array(), true, array(), array('email' => Filials::getEmail($client["filial_id"]), 'name' => Filials::getName($client["filial_id"])));
        $email->send();
    }
    ob_end_clean();
    header("location: ?type=remind&ok");
    die;
}
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
     Client::update($_SESSION["frame"]["client"]["id"], array('contacts' => $c));
     $_SESSION["frame"]["client"]["contacts"] = $c;
     $info = "Сохранено";
 }
 if (isset($_REQUEST["cab_prof_pwdchng"]) && is_array($_REQUEST["cab_prof_pwdchng"])) {
     $a = $_REQUEST["cab_prof_pwdchng"];
     if ($a["old"] == $_SESSION["frame"]["client"]["password"]) {
         if ($a["new"] == $a["rep"]) {
             $new = preg_replace("/[^0-9a-z]/i", "", $a["new"]);
             if (strlen($new) > 4 && strlen($new) < 21) {
                 $hpwd = md5($new . strtolower($_SESSION["frame"]["client"]["email"]));
                 Client::update($_SESSION["frame"]["client"]["id"], array('hpwd' => $hpwd, 'password' => $new));
                 $info = "Пароль изменен";
                 $txt = "<p>Здравствуйте, " . $_SESSION["frame"]["client"]["fio"] . "!</p>" . "Новый пароль для доступа к личному кабинету: <i>" . $new . "</i>" . "<p><i>С уважением, компания по написанию студенческих работ.</i></p>";
                 $email = new Email();
                 $email->setData(array('email' => $_SESSION["frame"]["client"]["email"], 'name' => $_SESSION["frame"]["client"]["fio"]), "Изменение пароля к личному кабинету", $txt, array(), true, array(), array('email' => Filials::getEmail($_SESSION["frame"]["client"]["filial_id"]), 'name' => Filials::getName($_SESSION["frame"]["client"]["filial_id"])));
                 if ($email->send()) {
                     $info .= ". Сообщение на почту отправлено.";
                 } else {
                     $info .= ". Не удалось отправить сообщение на почту.";
                 }
             } else {
                 $error = "Длина пароля должна быть 5-20 символов 0-9,a-z";
             }
         } else {
             $error = "Пароли не совпадают";
         }
     } else {
         $error = "Не верный текущий пароль";
     }
 }
Ejemplo n.º 8
0
 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));
 }