コード例 #1
0
 public function removeAction()
 {
     $Newsletters = new Application_Model_DbTable_Newsletter();
     $select = $Newsletters->select($Newsletters, array('id'))->where('email LIKE ?', $this->getRequest()->getParam("email"))->where('czy_potwierdzone = "t"');
     $newsletter = $Newsletters->fetchAll($select);
     if (count($newsletter) > 0) {
         $this->view->exist = true;
         $hash = TS_Salt::getSalt2();
         $data = array('ciag' => $hash);
         $Newsletters->update($data, array('id = ?' => intval($newsletter[0]->id)));
         $fullBaseUrl = $this->view->serverUrl() . $this->view->baseUrl();
         $urlParams = array('hash' => $hash);
         $mail = new TS_Mail();
         $mail_dane = array('to' => $this->getRequest()->getParam("email"), 'subject' => 'Potwierdzenie usunięcia newslettera', 'view' => array('script' => 'confirm-remove-newsletter', 'params' => array('baseUrl' => $fullBaseUrl, 'url' => $this->_helper->url('confirm-remove', 'newsletter', null, $urlParams))));
         /**/
         $mail->send($mail_dane);
     } else {
         $this->view->exist = false;
     }
 }
コード例 #2
0
ファイル: UserController.php プロジェクト: hYOUstone/tsg
 public function przypomnijhaslopotwierdzAction()
 {
     // action body
     if ($this->_request->isXmlHttpRequest()) {
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender(true);
         $post = $this->_request->getPost();
         $return = array('haslo' => true, 'test_nowe_haslo' => true);
         $ile_poprawnych = count($return) - 1;
         $zwroconych = 0;
         // haslo
         $notEmpty = new Zend_Validate_NotEmpty();
         $validatorString = new Zend_Validate();
         $validatorString->addValidator(new Zend_Validate_Alnum(), true);
         $validatorString->addValidator(new Zend_Validate_StringLength(array('min' => 6)));
         //$validatorString->addValidator(new Zend_Validate_Regex('/^[a-zA-Z0-9.]+$/'));
         if (!$notEmpty->isValid($post['haslo']) || !$notEmpty->isValid($post['haslo2'])) {
             $return['haslo'] = 'null';
         } elseif ($post['haslo'] != $post['haslo2']) {
             $return['haslo'] = 'diferent';
         } elseif (!$validatorString->isValid($post['haslo']) || !$validatorString->isValid($post['haslo2'])) {
             $return['haslo'] = 'incorect';
         } else {
             $salt = TS_Salt::getSalt3();
             $haslo = sha1($salt . $salt . $post['haslo'] . 69);
             $return['test_nowe_haslo'] = $haslo;
             $zwroconych++;
         }
         /**/
         // finalizowanie
         if ($ile_poprawnych == $zwroconych) {
             try {
                 $User = new Application_Model_DbTable_UzytkownicyWww();
                 $dane = array('password' => $haslo, 'salt' => $salt);
                 $User->update($dane, array('salt = ?' => $post['salt']));
                 /*$mail = new TS_Mail();
                   $mail_dane = array(
                     'to'      => '',
                     'subject' => 'Zmiana hasła',
                     'view'    => array(
                         'script'  =>  'zmianahasla',
                         'params'  => array()
                     ));
                   $mail->send($mail_dane);/**/
             } catch (Exception $ex) {
                 die($ex->getMessage());
             }
         }
         /**/
         echo json_encode($return);
     } else {
         $User = new Application_Model_DbTable_UzytkownicyWww();
         //echo 'dupa:'.$this->_request->getParam("salt");
         if ($this->_request->getParam("salt") && $User->czySalt($this->_request->getParam("salt"))) {
             $this->view->nowehaslo = new Application_Form_ZmianaHasla();
         } else {
             return $this->_helper->redirector('brakautoryzacji', 'user');
         }
     }
 }