function init() { $this->initView(); $this->view->baseUrl = $this->_request->getBaseUrl(); $user = My_Auth::getInstance('Painel')->getStorage()->read(); $this->view->user = $user; }
function init() { if (!My_Auth::getInstance('Painel')->hasIdentity()) { $this->_redirect('painel/auth'); } $this->initView(); $this->view->baseUrl = $this->_request->getBaseUrl(); $user = My_Auth::getInstance('Painel')->getStorage()->read(); $this->view->user = $user; $message = null; //manha = 60000 //tarde = 120000 //noite = 190000 //madrugada = 235900 $now = (int) date('Gis'); switch ($now) { case $now > 60000 && $now < 120000: $message = 'Bom dia, ' . $user->name . '!'; break; case $now > 120000 && $now < 190000: $message = 'Boa tarde, ' . $user->name . '!'; break; case $now > 190000 && $now < 235900: $message = 'Boa noite, ' . $user->name . '!'; break; case $now > 00 && $now < 60000: $message = 'Já esta tarde ' . $user->name . ', não é melhor dormir?'; break; } $this->view->message = $message; }
public function logoutAction() { $userSession = My_Auth::getInstance('Painel')->getStorage()->read(); $id = (int) $userSession->id; if ($id !== false) { My_Auth::getInstance('Painel')->clearIdentity(); $this->_redirect('painel/index'); } }
function init() { if (!My_Auth::getInstance('Painel')->hasIdentity()) { $this->_redirect('painel/auth'); } $this->initView(); $this->view->baseUrl = $this->_request->getBaseUrl(); $user = My_Auth::getInstance('Painel')->getStorage()->read(); $this->view->user = $user; }
public function preDispatch(Zend_Controller_Request_Abstract $request) { if ($request->getModuleName() === 'painel') { if (My_Auth::getInstance('Painel')->hasIdentity()) { return; } else { if ($request->getControllerName() !== 'auth') { $uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(); $r = new Zend_Controller_Action_Helper_Redirector(); $r->gotoUrl('painel/auth?u=' . base64_encode($uri))->redirectAndExit(); } } } }
public function init() { $this->initView(); $user = My_Auth::getInstance('Painel')->getStorage()->read(); $this->view->user = $user; }
public function logoutAction() { $adminAuth = new My_Auth("admin"); $adminAuth->clearIdentity(); $this->_helper->redirector('index', 'auth'); }
public function editarAction() { $request = $this->getRequest(); $id = $request->getParam('id'); $user = My_Auth::getInstance('Painel')->getStorage()->read(); $pt = new Postagem(); $ct = new Categoria(); $postagem = $pt->getPostagemById($id); if ($request->isPost()) { $erro = false; $msg = ''; $date = new Zend_Date(); $now = $date->toString('YYYY-MM-dd HH:mm:ss'); $pt->setTitulo($request->getPost('titulo')); $pt->setPostagem($request->getPost('postagem')); $pt->setCagegoriaId($request->getPost('categoria_id')); $pt->setUsuarioId($user->id); $pt->setTags($request->getPost('tags')); $pt->setAlteradoem($now); $data = array('titulo' => $pt->getTitulo(), 'postagem' => $pt->getPostagem(), 'categoria_id' => $pt->getCagegoriaId(), 'usuario_id' => $pt->getUsuarioId(), 'tags' => $pt->getTags(), 'alteradoem' => $pt->getAlteradoem()); $pt->savePostagem($data, $id); if ($request->getPost('imagem')) { $imageName = time() . '_saved.jpg'; $imagem = json_decode($request->getPost('imagem')); $base64 = base64_decode(preg_replace('#^data:image/[^;]+;base64,#', '', $imagem->image)); // create image $source = imagecreatefromstring($base64); if (!file_exists(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'blog' . DS . $postagem_id)) { mkdir(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'blog' . DS . $postagem_id, 0777, true); } $url = ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'blog' . DS . $postagem_id . DS . $imageName; imagejpeg($source, $url, 100); $pt->setImagem($imageName); $data = array('imagem' => $pt->getImagem()); if (!$pt->savePostagem($data, $postagem_id)) { $erro = true; } } if ($erro) { $msg = 'Ocorreu um erro, tente novamente'; $this->view->msg = $msg; } else { $this->_helper->redirector('listar', 'postagens'); } } $this->view->postagem = $postagem; $this->view->categorias = $ct->getAllCategoria(); $this->render(); }
public function logoutAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $this->user->accessToken = null; //Clear AccessToken in My_Auth::Storage (Session); $storage = My_Auth::getInstance('Painel')->getStorage(); $storage->write($this->user); $this->_redirect('painel/facebook'); }
public function logoutAction() { $auth = new My_Auth("user"); $result = $auth->clearIdentity(); $this->_helper->redirector('index', 'index'); $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); }