Example #1
0
 public function getFullIdentity($identyfikator)
 {
     $Users = new Application_Model_DbTable_UzytkownicyWww();
     $select = $Users->select()->where('username = ?', $identyfikator)->where('czy_aktywne = ?', 'T');
     $userData = $Users->fetchAll($select);
     return $userData[0];
     //return "oO";
 }
Example #2
0
 public function czyLogin($login)
 {
     $Users = new Application_Model_DbTable_UzytkownicyWww();
     $select = $Users->select(array('id'))->where('czy_aktywne = ?', "T")->where('username = ?', $login);
     //$return = $select->__toString()." / ".count($Users->fetchAll($select));
     //return $return;
     //return $select->__toString();
     return count($this->fetchAll($select));
 }
Example #3
0
 public function isValid($value, $context = null)
 {
     $email = $value;
     $this->_setValue($email);
     if (is_array($context) && isset($context['username']) && ($username = $context['username'])) {
         $User = new Application_Model_DbTable_UzytkownicyWww();
         $select = $User->select()->where('username = ?', $username);
         $u = $User->fetchRow($select);
         if ($u && $u['email'] === $email) {
             return true;
         }
     }
     $this->_error(self::NOT_FOUND);
     return false;
 }
Example #4
0
 public function create($username = '', $password = '')
 {
     $username = trim(strtolower($username));
     $password = trim(strtolower($password));
     if (!$username || !$password) {
         $this->_registry->getResponse()->appendContent("Podaj nazwe konta i haslo.");
         return;
     }
     // Define path to application directory
     defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
     // Define application environment
     defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development');
     // Ensure library/ is on include_path
     set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path())));
     /** Zend_Application */
     require_once 'Zend/Application.php';
     // Create application, bootstrap, and run
     $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
     $application->bootstrap('db');
     $User = new Application_Model_DbTable_UzytkownicyWww();
     $salt = My_Salt::getSalt3();
     $dane = array('login_pre' => $username, 'haslo_pre' => sha1($salt . $salt . $password), 'salt' => $salt);
     $User->createRow($dane)->save();
 }
Example #5
0
 public function dodajkomentarzAction()
 {
     // action body
     if ($this->_request->isXmlHttpRequest()) {
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender(true);
         $post = $this->_request->getPost();
         //$post_e = json_encode($this->_request->getPost());
         //$post_d = json_decode($this->_request->getPost());
         $return = array('tytul' => true, 'tresc' => true, 'podpis' => true);
         // sprawdzanie
         $Users = new Application_Model_DbTable_UzytkownicyWww();
         $isvalid = new Zend_Validate_NotEmpty();
         $ile_poprawnych = 3;
         $zwroconych = 0;
         if (!$isvalid->isValid($post['tytul'])) {
             $return['tytul'] = 'null';
         } else {
             $zwroconych++;
         }
         if (!$isvalid->isValid($post['tresc'])) {
             $return['tresc'] = 'null';
         } else {
             $zwroconych++;
         }
         if (!$isvalid->isValid($post['podpis'])) {
             $return['podpis'] = 'null';
         } elseif (!Zend_Auth::getInstance()->hasIdentity() && $Users->ilePodpisow($post['podpis']) > 0) {
             $return['podpis'] = 'isvalid';
         } else {
             $zwroconych++;
         }
         echo json_encode($return);
         // dodawanie
         if ($ile_poprawnych == $zwroconych) {
             $Komentarz = new Application_Model_DbTable_AnkietyKomentarze();
             $dane = array('tytul' => $post['tytul'], 'podpis' => $post['podpis'], 'tresc' => $post['tresc'], 'id_ankiety' => intval($this->getRequest()->getParam("id")), 'czy_wyswietlac' => 'n', 'ip' => $_SERVER['REMOTE_ADDR'], 'data_dodania' => new Zend_Db_Expr('NOW()'));
             try {
                 $Komentarz->createRow($dane)->save();
             } catch (Exception $ex) {
                 die($e->getMessage());
             }
         }
     }
 }
Example #6
0
 public function potwierdzdotpayAction()
 {
     // action body
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $post = $this->_request->getPost();
     if ($post) {
         $User = new Application_Model_DbTable_UzytkownicyWww();
         $select = $User->select()->where('id = ?', intval($post['control']));
         $user = $User->fetchRow($select);
         switch ($post['status']) {
             case 'OK':
                 if ($user && $post['amount'] == 5) {
                     //if(strtotime(date("Y-m-d H:i:s"))<strtotime(date("Y-m-d H:i:s", strtotime($u->abonament_art_do))) && $u->abonament_art_do!="0000-00-00 00:00:00")
                     //  $wazna_do = strtotime(date("Y-m-d H:i:s", strtotime($u->abonament_art_do) . " +1 month"));
                     //else
                     $wazna_do = date('Y-m-d H:i:s', strtotime("+1 month"));
                     $user->abonament_art_do = $wazna_do;
                     $user->save();
                     if ($user->email != "") {
                         /*$mail = new TS_Mail_Gmail();
                           $mail->send(array(
                               'to'      => $user->email,
                               'subject' => 'Płatność on-line',
                               'body'    => "Płatność została zakończona powodzeniem. Abonament ważny do {$wazna_do}"
                           ));*/
                         $mail = new TS_Mail_Netart();
                         $mail->send(array('to' => $user->email, 'subject' => 'Płatność on-line', 'body' => "Płatność została zakończona powodzeniem. Abonament ważny do {$wazna_do}."));
                     }
                 }
                 break;
             case 'FAIL':
                 if ($user && $_POST['amount'] == 5) {
                     if ($user->email != "") {
                         /*$mail = new TS_Mail_Gmail();
                           $mail->send(array(
                               'to'      => $user->email,
                               'subject' => 'Płatność on-line',
                               'body'    => "Płatność została zakończona niepowodzeniem. Skontaktuj się z redakcją aby wyjaśnić problem."
                           ));*/
                         $mail = new TS_Mail_Netart();
                         $mail->send(array('to' => $user->email, 'subject' => 'Płatność on-line', 'body' => "Płatność została zakończona niepowodzeniem. Skontaktuj się z redakcją aby wyjaśnić problem."));
                     }
                 }
                 break;
         }
     }
     echo "OK";
 }
Example #7
0
 public function loginAction()
 {
     // uzytkownik jest juz zalogowany, przekierujmy go na strone glowna
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_redirect('/');
     }
     // zapisanie do sesji informacji o adresie powrotu
     $session = new Zend_Session_Namespace('signreferer');
     if (!isset($session->referer) && isset($_SERVER['HTTP_REFERER'])) {
         // sprawdzenie, czy referer pochodzi z tej samej domeny
         if (parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) == $_SERVER['HTTP_HOST']) {
             $session->referer = $_SERVER['HTTP_REFERER'];
         }
     }
     $form = new Application_Form_LogowanieDuze();
     $postData = $this->getRequest()->getPost();
     if ($postData) {
         //            var_dump($postData); die;
         if ($form->isValid($postData)) {
             // stworzenie obiektu Zend_Auth
             $auth = Zend_Auth::getInstance();
             $authAdapter = new Zend_Auth_Adapter_DbTable(null, 'ts_wydania_prenumerata_users_pl', 'username', 'password', 'SHA1(CONCAT(salt, salt, ?, 69)) AND czy_aktywne="T"');
             //$authAdapter->setIdentityColumn('username');
             $authAdapter->setIdentity($form->getValue('username'));
             $authAdapter->setCredential($form->getValue('password'));
             $result = $auth->authenticate($authAdapter);
             $auth = Zend_Auth::getInstance();
             if ($auth->getIdentity()) {
                 $user = TS_Auth::getFullIdentity($auth->getIdentity());
                 $rememberHashTag = TS_Auth::getSalt3();
                 $User = new Application_Model_DbTable_UzytkownicyWww();
                 $newData = array('data_ostatniego_logowania' => new Zend_Db_Expr('NOW()'), 'salt' => $rememberHashTag);
                 $User->update($newData, array('id = ?' => $user->id));
                 setcookie('rememberUser', $rememberHashTag, time() + 10 * 365 * 24 * 60 * 60, '/', $_SERVER['SERVER_NAME']);
                 if ($result->isValid()) {
                     // powrót do linku sprzed logowania
                     $returnUrl = '/';
                     if (isset($session->referer)) {
                         $returnUrl = $session->referer;
                     }
                     unset($session->referer);
                     return $this->_redirect($returnUrl);
                     /*
                                             return $this->_helper->redirector(
                                                 'index',
                                                 'index',
                                                 'default'
                                             );*/
                 }
             }
             // nadpisanie formularza duzym formularzem
             $form = new Application_Form_LogowanieDuze();
             $form->populate($postData);
             //                $form->password->addError('Błędna próba logowania!');
         } else {
             if ($form->getErrors("username")) {
                 $form->getElement("username")->setAttrib("class", "form-control auth-error");
             }
             if ($form->getErrors("password")) {
                 $form->getElement("password")->setAttrib("class", "form-control auth-error");
             }
         }
     }
     //return $this->_helper->redirector('brakautoryzacji', 'user', null, array('komunikat'=>"błędne dane"));
     $this->view->form = $form;
     $this->view->googleAuthUrl = TBS\Auth\Adapter\Google::getAuthorizationUrl();
     $this->view->googleAuthUrlOffline = TBS\Auth\Adapter\Google::getAuthorizationUrl(true);
     $this->view->facebookAuthUrl = TBS\Auth\Adapter\Facebook::getAuthorizationUrl();
     $this->view->twitterAuthUrl = \TBS\Auth\Adapter\Twitter::getAuthorizationUrl();
     $this->view->instagramAuthUrl = \TBS\Auth\Adapter\Instagram::getAuthorizationUrl();
 }
Example #8
0
 public function kupwydaniepojedynczepktAction()
 {
     // action body
     $Numer = new Application_Model_DbTable_Numery();
     $select = $Numer->fetchRow($Numer->select()->from($Numer, array('id', 'tytul', 'foto'))->where('id = ?', intval($this->getRequest()->getParam("id")))->where('czy_wyswietlac = ?', 1)->where('od_kiedy_wyswietlac <= ?', new Zend_Db_Expr('NOW()')));
     //
     if (count($select) > 0) {
         $this->view->numer = $select;
     } else {
         throw new Zend_Controller_Action_Exception(404);
     }
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         $this->view->logowanieduze = new Application_Form_LogowanieDuze();
     } else {
         $this->view->user = TS_Auth::getFullIdentity($auth->getIdentity());
         $this->view->postUrl = $this->view->url(array('controller' => 'Wydania', 'action' => 'kupwydaniepojedynczepkt', 'id' => intval($this->getRequest()->getParam("id"))), 'default', TRUE);
         if ($this->_request->isXmlHttpRequest()) {
             $this->_helper->layout->disableLayout();
             $this->_helper->viewRenderer->setNoRender(true);
             //            $this->getResponse()->setHeader('Content-Type', 'application/json');
             $post = $this->_request->getPost();
             $return = array('konsumenckie' => true, 'punkty' => true, 'wydaniaLinki' => array());
             $ile_poprawnych = count($return) - 1;
             $zwroconych = 0;
             // regulamin
             if ($post['konsumenckie'] == 'false') {
                 $return['konsumenckie'] = false;
             } else {
                 $zwroconych++;
             }
             /**/
             // pnkty
             if ($this->view->user->punkty <= 0) {
                 $return['punkty'] = false;
             } else {
                 $zwroconych++;
             }
             /**/
             if ($ile_poprawnych == $zwroconych) {
                 $Numer = new Application_Model_DbTable_Numery();
                 $Numer->update(array('wersja_elektroniczna_zakupy' => new Zend_Db_Expr('wersja_elektroniczna_zakupy + 1')), array('id = ?' => intval($this->getRequest()->getParam("id"))));
                 $Zakup = new Application_Model_DbTable_WydaniaPrenumerataZakup();
                 $data = array('id_wydania' => intval($this->getRequest()->getParam("id")), 'id_prenumeratora' => $this->view->user->id, 'data_zakupu' => new Zend_Db_Expr('NOW()'));
                 $id_zakupu = $Zakup->createRow($data)->save();
                 $User = new Application_Model_DbTable_UzytkownicyWww();
                 $User->update(array('punkty' => new Zend_Db_Expr('punkty - 1')), array('id = ?' => intval($this->view->user->id)));
                 $WydaniePliki = new Application_Model_DbTable_WydaniaPliki();
                 $select = $WydaniePliki->select()->where('id_numeru = ?', intval($this->getRequest()->getParam("id")));
                 //$return['test'] = $select->__toString();
                 $wydaniapliki = $WydaniePliki->fetchAll($select);
                 $WydaniaPlikiUzyciaPrenumerata = new Application_Model_DbTable_WydaniaPlikiUzyciaPrenumerata();
                 foreach ($wydaniapliki as $wydaniaplik) {
                     $data = array('id_zakupu' => $id_zakupu, 'id_pliku' => $wydaniaplik['id'], 'liczba_uzyc' => 0);
                     $WydaniaPlikiUzyciaPrenumerata->createRow($data)->save();
                 }
                 $fullBaseUrl = $this->view->serverUrl() . $this->view->baseUrl();
                 $mail = new TS_Mail();
                 $mail_dane = array('to' => $this->view->user->email, 'subject' => 'Pobieranie e-wydania', 'view' => array('script' => 'pobierzwydanieprenumerata', 'params' => array('tytul_numeru' => $Numer->pokazTytul(intval($this->getRequest()->getParam("id"))), 'wydaniapliki' => $wydaniapliki, 'zakup' => $id_zakupu, 'baseUrl' => $fullBaseUrl)));
                 /**/
                 $mail->send($mail_dane);
                 if (isset($wydaniapliki) && count($wydaniapliki) > 0 && isset($id_zakupu)) {
                     $return['wydaniaLinki'] = $this->generujLinki($wydaniapliki, 'pkt', $id_zakupu);
                 }
             }
             echo json_encode($return);
         }
     }
 }
Example #9
0
 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');
         }
     }
 }