Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function insert_user($respon){
- try {
- $recaptcha=$respon['g-recaptcha-response'];
- if(!empty($recaptcha)) {
- $google_url = "https://www.google.com/recaptcha/api/siteverify";
- $secret = '6Ld9134UAAAAAKDtW4t5WswxaNo6nRsT6UopGPSM';
- $ip = $_SERVER['REMOTE_ADDR'];
- $url = $google_url . "?secret=" . $secret . "&response=" . $recaptcha . "&remoteip=" . $ip;
- $res = $this->getCurlData($url);
- $res = json_decode($res, true);
- //reCaptcha введена
- if ($res['success']) {
- $r['log'] = $this->replace_attr($respon['log']);
- $r['pas'] = $this->replace_attr_md5($respon['pas']);
- $r['nam'] = $this->replace_attr($respon['nam']);
- $r['tel'] = $this->replace_attr($respon['tel']);
- $r['mail'] = $this->replace_attr($respon['mail']);
- $r['org'] = $this->replace_attr($respon['org']);
- $r['status'] = 0;
- $r['adres'] = $this->replace_attr($respon['adres']);
- $q = $this->dbs->prepare("select * from users where login=:login;");
- $q->execute([':login' => $r['log']]);
- if ($q->rowCount() != 0) {
- echo json_encode(array("naz" => "Сообщение", "mes" => "Пользователь с таким логином уже существует"), JSON_UNESCAPED_UNICODE);
- } else {
- #print "insert into users(login, pasw, nam, tel, adres, mail, status, org) values(" . $r['log'] . ", " . $r['pas'] . ", " . $r['nam'] . ", " . $r['tel'] . ", " . $r['adres'] . ", " . $r['mail'] . ", " . $r['status'] . ", " . $r['org'] . ");";
- $s = $this->dbs->prepare("insert into users(login, pasw, nam, tel, adres, mail, status, org) values(:login, :pasw, :nam, :tel, :adres, :mail, :status, :org);");
- if ($s->execute([':login' => $r['log'], ':pasw' => $r['pas'], ':nam' => $r['nam'], ':tel' => $r['tel'], ':adres' => $r['adres'], ':mail' => $r['mail'], ':status' => $r['status'], ':org' => $r['org']])) {
- echo json_encode(array("naz" => "Сообщение:", "mes" => "Пользователь успешно зарегистрирован"), JSON_UNESCAPED_UNICODE);
- } else echo json_encode(array("naz"=>"Сообщение:", "mes" => "Произошла ошибка при регистрации пользователя"), JSON_UNESCAPED_UNICODE);
- }
- }else echo json_encode(array("naz" => "Сообщение:", "mes" => "Пожалуйста повторите ввод reCAPTCHA"), JSON_UNESCAPED_UNICODE);
- }else echo json_encode(array("naz" => "Сообщение:", "mes" => "Пожалуйста повторите ввод reCAPTCHA"), JSON_UNESCAPED_UNICODE);
- } catch (PDOException $e) {
- print $e;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement