public function rejestracjasprawdzAction() { // action body if ($this->_request->isXmlHttpRequest()) { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $post = $this->_request->getPost(); $return = array('login' => true, 'haslo' => true, 'imie' => true, 'nazwisko' => true, 'podpis' => true, 'email' => true, 'nip' => true, 'regulamin' => true); $ile_poprawnych = count($return); $zwroconych = 0; $empty = new Zend_Validate_NotEmpty(); // login $Users = new Application_Model_DbTable_UzytkownicyWww(); //$return['test'] = $Users->czyLogin($post['login']); $validatorString = new Zend_Validate_StringLength(array('min' => 4)); if (!$empty->isValid($post['login'])) { $return['login'] = '******'; } elseif (!$validatorString->isValid($post['login'])) { $return['login'] = '******'; } elseif ($Users->czyLogin($post['login']) > 0) { $return['login'] = '******'; } else { $zwroconych++; } /**/ // haslo $validatorString = new Zend_Validate_StringLength(array('min' => 6)); if (!$empty->isValid($post['haslo']) || !$empty->isValid($post['haslo2'])) { $return['haslo'] = 'null'; } elseif (!$validatorString->isValid($post['haslo']) || !$validatorString->isValid($post['haslo2'])) { $return['haslo'] = 'length'; } elseif ($post['haslo'] != $post['haslo2']) { $return['haslo'] = 'diferent'; } else { $zwroconych++; } /**/ // imie if (!$empty->isValid($post['imie'])) { $return['imie'] = 'null'; } else { $zwroconych++; } /**/ // nazwisko if (!$empty->isValid($post['nazwisko'])) { $return['nazwisko'] = 'null'; } else { $zwroconych++; } /**/ // podpis if (!$empty->isValid($post['podpis'])) { $return['podpis'] = 'null'; } elseif ($Users->ilePodpisow($post['podpis']) > 0) { $return['podpis'] = 'exist'; } else { $zwroconych++; } /**/ // email $isvalidEmail = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS | Zend_Validate_Hostname::ALLOW_LOCAL); $emailIsExist = new Zend_Validate_Db_NoRecordExists(array('table' => 'ts_wydania_prenumerata_users_pl', 'field' => 'email', 'exclude' => array('field' => 'czy_aktywne', 'value' => 'N'))); if (!$empty->isValid($post['email'])) { $return['email'] = 'null'; } elseif (!$isvalidEmail->isValid($post['email'])) { $return['email'] = 'wrong'; } elseif (!$emailIsExist->isValid($post['email'])) { $return['email'] = 'exist'; } else { $zwroconych++; } /**/ // regulamin if ($post['regulamin'] == 'false') { $return['regulamin'] = 'null'; } else { $zwroconych++; } /**/ // nip $isvalidNip = new Zend_Validate_Nip(); if ($empty->isValid($post['nip']) && !$isvalidNip->isValid($post['nip'])) { $return['nip'] = 'niperr'; } else { $zwroconych++; } /**/ echo json_encode($return); // finalizowanie if ($ile_poprawnych == $zwroconych) { try { $salt = TS_Salt::getSalt3(); $User = new Application_Model_DbTable_UzytkownicyWww(); $dane = array('username' => $post['login'], 'login_pre' => $post['login'], 'password' => md5($post['haslo']), 'haslo_pre' => md5($post['haslo']), 'imie' => $post['imie'], 'nazwisko' => $post['nazwisko'], 'podpis' => $post['podpis'], 'email' => $post['email'], 'telefon' => $post['telefon'], 'nazwa_firmy' => $post['firma'], 'nip' => $post['nip'], 'ulica' => $post['ulica'], 'nr_domu' => $post['nr_budynku'], 'nr_mieszkania' => $post['nr_mieszkania'], 'miasto' => $post['miasto'], 'kod_pocztowy' => $post['kod_pocztowy'], 'poczta' => $post['poczta'], 'czy_aktywne' => "N", 'data_rejestracji' => new Zend_Db_Expr('NOW()'), 'salt' => $salt); $User->createRow($dane)->save(); $linkPotwierdzajacy = $this->view->serverUrl() . $this->view->baseUrl() . $this->view->url(array('controller' => 'user', 'action' => 'rejestracjapotwierdz', 'salt' => $salt), null, false); $mail = new TS_Mail(); $mail_dane = array('to' => $post['email'], 'subject' => 'Potwierdzenie rejestracji', 'view' => array('script' => 'potwierdzrejestracje', 'params' => array('salt' => $salt, 'baseUrl' => $this->view->serverUrl() . $this->view->baseUrl(), 'linkPotwierdzajacy' => $linkPotwierdzajacy))); $mail->send($mail_dane); } catch (Exception $ex) { die($ex->getMessage()); } } /**/ } }