public function pokaz() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $view = Zend_Layout::getMvcInstance()->getView(); $user = TS_Auth::getFullIdentity($auth->getIdentity()); ?> <table class="user_menu_linki" align="center" cellpadding="2" cellspacing="2"> <tr class="info"> <td colspan="3" align="left"><b><?php echo $user->imie; ?> <?php echo $user->nazwisko; ?> </b><br><br></td> <td colspan="3" align="right"><b>Twoje punkty: <?php echo $user->punkty; ?> </b><br><br></td> </tr> <tr> <td align="center" class="link" width="10%"><a class="user_menu_link" href="<?php echo $view->url(array('rok' => 2013), 'wydania', true); ?> "><img src="http://old.tygodniksiedlecki.com/img/ico/basket_add.png" border="0" title="Pobierz numer TS" alt="Pobierz numer TS"><br>E-wydania</a></td> <td align="center" class="link" width="14%"><a class="user_menu_link" href="<?php echo $view->url(array(), 'user-dokuppunkty', true); ?> "><img src="http://old.tygodniksiedlecki.com/img/ico/basket.png" border="0" title="Dokup punkty" alt="Dokup punkty"><br>Dokup punkty</a></td> <td align="center" class="link" width="14%"><a class="user_menu_link" href="<?php echo $view->url(array(), 'user-historiapobran', true); ?> "><img src="http://old.tygodniksiedlecki.com/img/ico/moje_ogl.png" border="0" title="Historia pobrań" alt="Historia pobrań"><br>Historia pobrań</a></td> <td align="center" class="link" width="14%"><a class="user_menu_link" href="<?php echo $view->url(array(), 'user-historiazamowien', true); ?> "><img src="http://old.tygodniksiedlecki.com/img/ico/moje_ogl2.png" border="0" title="Historia zamówień" alt="Historia zamówień"><br>Historia zamówień</a></td> <td align="center" class="link" width="14%"><a class="user_menu_link" href="<?php echo $view->url(array(), 'user-ustawienia', true); ?> "><img src="http://old.tygodniksiedlecki.com/img/ico/ogl_konto.png" border="0" title="Ustawienia konta" alt="Ustawienia konta"><br>Ustawienia konta</a></td> <td align="center" class="link" width="14%"><a class="user_menu_link" href="<?php echo $view->url(array('controller' => 'auth', 'action' => 'logout'), 'default', TRUE); ?> "><img src="http://old.tygodniksiedlecki.com/img/ico/exit24.png" border="0"><br>Wyloguj</a></td> </tr> </table> <br> <hr> <?php } }
public function init() { /* Form Elements & Other Definitions Here ... */ $decorator = new TS_Decorators_Decorator(); $url = $this->getView()->url(array('controller' => 'sonda', 'action' => 'dodajkomentarz', 'id' => Zend_Controller_Front::getInstance()->getRequest()->getParam('id')), 'default'); //$this->setMethod('post'); //$this->setAction($url); $this->addDecorators(array('FormElements', array('Form', array('id' => 'dodaj_komentarz_sonda_form')))); $this->setAttrib('id', 'dodaj_komentarz_sonda_form'); // tytul $this->addElement('text', 'tytul', array('label' => 'Tytuł:', 'size' => 79, 'value' => '', 'required' => true, 'filters' => array('StringTrim'), 'decorators' => array($decorator), 'id' => 'kom_tytul', 'class' => 'def')); // tresc $this->addElement('textarea', 'tresc', array('label' => 'Treść:', 'cols' => '90', 'rows' => '5', 'value' => '', 'required' => true, 'filters' => array('StringTrim'), 'decorators' => array($decorator), 'id' => 'kom_tresc', 'class' => 'def')); //$podpisValue = TS_Auth::getFullIdentity(); // podpis $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $user = TS_Auth::getFullIdentity($auth->getIdentity()); $this->addElement('text', 'podpis', array('label' => 'Podpis:', 'size' => 30, 'value' => $user->podpis, 'required' => true, 'filters' => array('StringTrim'), 'decorators' => array($decorator), 'id' => 'kom_podpis', 'class' => 'def', 'readonly' => 'readonly')); } else { $this->addElement('text', 'podpis', array('label' => 'Podpis:', 'size' => 30, 'value' => '', 'required' => true, 'filters' => array('StringTrim'), 'decorators' => array($decorator), 'id' => 'kom_podpis', 'class' => 'def', 'readonly' => '', 'validators' => array(array('Db_NoRecordExists', true, array('table' => 'ts_wydania_prenumerata_users_pl', 'field' => 'podpis'))))); } // url $this->addElement('hidden', 'url', array('label' => '', 'value' => $url, 'required' => true, 'decorators' => array($decorator), 'id' => 'kom_url')); // submit $this->addElement('button', 'submit', array('ignore' => true, 'label' => '', 'value' => 'dodaj', 'decorators' => array($decorator), 'id' => 'kom_submit')); /* $this->addElement( 'submit', 'submit', array( 'ignore' => true, 'label' => '', 'value' => 'dodaj', 'decorators' => array($decorator), ) );*/ }
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); } } }
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(); }
public function historiazamowienAction() { // action body $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $this->view->user = TS_Auth::getFullIdentity($auth->getIdentity()); $Zamowienia = new Application_Model_DbTable_WydaniaPrenumerataZamowienia(); $select = $Zamowienia->select()->where('id_prenumeratora = ?', $this->view->user->id)->order('id DESC'); $zamowienia = $Zamowienia->fetchAll($select); $paginator = Zend_Paginator::factory($zamowienia); $paginator->setItemCountPerPage(20)->setCurrentPageNumber($this->_getParam('page', 1)); $this->view->paginator = $paginator; $Numery = new Application_Model_DbTable_Numery(); $this->view->numery = $Numery; } else { return $this->_helper->redirector('brakautoryzacji', 'user'); } }