public function saveAction()
 {
     $db = new Login();
     $db->setLogin('testes');
     $db->setSenha('1234');
     $db->setTipoId(1);
     $db->setBloqueado(0);
     $data = array('login' => $db->getLogin(), 'senha' => $db->getSenha(), 'tipoid' => $db->getTipoId(), 'bloqueado' => $db->getBloqueado());
     $return = $db->saveLogin($data, 2);
     $this->view->retorno = $return;
     $this->render();
 }
<?php

require_once "../class/ConDB.class.php";
$lgn = new Login();
print $lgn->setLogin($_POST['email'], $_POST['senha']);
 public function setNewPasswordAction()
 {
     $this->form3 = $this->getServiceLocator()->get($this->form3);
     if (is_string($this->form3)) {
         $form = new $this->form3();
     } else {
         $form = $this->form3;
     }
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $arrayRequest = $request->getPost()->toArray();
             $login = new Login();
             $login->setLogin($form->get('login')->getValue());
             $login->setSenha($login->encryptPassword($form->get('senha')->getValue()));
             $usuario = new Usuario();
             $usuario->setNome($arrayRequest['nome']);
             $usuario->setEmail($arrayRequest['email']);
             //$em = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
             $em = $this->getEm();
             $em->getConnection()->beginTransaction();
             // suspend auto-commit
             try {
                 $em->persist($login);
                 $em->flush();
                 $usuario->setLogin($em->getRepository('Login\\Entity\\Login')->find($login->getId()));
                 $usuario->setNivel($em->getRepository('Nivel\\Entity\\Nivel')->find($arrayRequest['nivel']));
                 $em->persist($usuario);
                 $em->flush();
                 $em->getConnection()->commit();
                 $this->flashMessenger()->addSuccessMessage('Cadastrado com Sucesso');
             } catch (Exception $e) {
                 $em->getConnection()->rollback();
                 var_dump('eeeee');
                 die;
                 $this->flashMessenger()->addErrorMessage('Nao foi possivel cadastrar!');
                 //throw $e;
             }
             return $this->redirect()->toRoute($this->route, array('controller' => $this->controller, 'action' => 'inserir'));
         }
     }
     if ($this->flashMessenger()->hasSuccessMessages()) {
         return new ViewModel(array('form' => $form, 'success' => $this->flashMessenger()->getSuccessMessages()));
     }
     if ($this->flashMessenger()->hasErrorMessages()) {
         return new ViewModel(array('form' => $form, 'error' => $this->flashMessenger()->getErrorMessages()));
     }
     $this->flashMessenger()->clearMessages();
     return new ViewModel(array('form' => $form));
 }
 public function cadastrarAction()
 {
     $tp = new LoginTipo();
     $grupos = new AclGrupos();
     $tiposLogin = $tp->getAllLoginTipo();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $db = new Login();
         $us = new Usuarios();
         $ut = new Util();
         $erro = false;
         $msg = '';
         $db->setLogin($request->getPost('Login'));
         $db->setSenha($request->getPost('Senha'));
         $db->setTipoId($request->getPost('TipoId'));
         $dataLogin = array('login' => $db->getLogin(), 'senha' => $db->getSenha(), 'tipoid' => $db->getTipoId());
         if (!($login_id = $db->saveLogin($dataLogin))) {
             $erro = true;
         }
         $nascimento = empty($request->getPost('Nascimento')) ? NULL : $ut->dateToSql($request->getPost('Nascimento'));
         $now = $ut->nowDateSql();
         $rg = $ut->limpaDados($request->getPost('Rg'));
         $cpf = $ut->limpaDados($request->getPost('Cpf'));
         $telefone = $ut->limpaDados($request->getPost('Telefone'));
         $celular = $ut->limpaDados($request->getPost('Celular'));
         $us->setNome($request->getPost('Nome'));
         $us->setSobrenome($request->getPost('Sobrenome'));
         $us->setEmail($request->getPost('Email'));
         $us->setLoginId($login_id);
         $us->setRg($rg);
         $us->setCpf($cpf);
         $us->setNascimento($nascimento);
         $us->setTelefone($telefone);
         $us->setCelular($celular);
         $us->setSexo($request->getPost('Sexo'));
         $us->setCadastradoEm($now);
         $dataUser = array('nome' => $us->getNome(), 'sobrenome' => $us->getSobrenome(), 'email' => $us->getEmail(), 'login_id' => $us->getLoginId(), 'rg' => $us->getRg(), 'cpf' => $us->getCpf(), 'nascimento' => $us->getNascimento(), 'telefone' => $us->getTelefone(), 'celular' => $us->getCelular(), 'sexo' => $us->getSexo(), 'cadastradoem' => $us->getCadastradoEm());
         if ($usuario_id = $us->saveUser($dataUser)) {
             $adapter = new Zend_File_Transfer_Adapter_Http();
             $adapter->setDestination(APPLICATION_PATH . '/../data/temp');
             $upload = new Zend_File_Transfer();
             $files = $upload->getFileInfo();
             if ($files['Avatar']['tmp_name']) {
                 if (!file_exists(ROOT_DIR . DS . 'painel' . DS . 'images' . DS . 'usuario' . DS . $login_id)) {
                     mkdir(ROOT_DIR . DS . 'painel' . DS . 'images' . DS . 'usuario' . DS . $login_id, 0777, true);
                 }
                 foreach ($files as $file => $info) {
                     if ($upload->isUploaded($file)) {
                         //$extension = substr($info['name'], strrpos($info['name'], '.') + 1);
                         $filename = 'avatar.jpg';
                         $adapter->addFilter('Rename', array('target' => APPLICATION_PATH . '/../data/temp/' . $filename, 'overwrite' => true));
                         $adapter->receive($info['name']);
                         if (!$adapter->receive()) {
                             $messages = $adapter->getMessages();
                             echo implode("\n", $messages);
                             exit;
                         }
                         //setFileName::Url2
                         $us->setAvatar($filename);
                         $imanee = new Imanee\Imanee(APPLICATION_PATH . '/../data/temp/' . $filename);
                         //resized
                         $imanee->resize(300, 300)->write(ROOT_DIR . DS . 'painel' . DS . 'images' . DS . 'usuario' . DS . $login_id . DS . $filename, 80);
                         //full
                         //$imanee->resize(1024, 768)
                         //        ->write(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'galeria' . DS . $album_id . DS . 'f_' . $filename, 80);
                         unlink(APPLICATION_PATH . '/../data/temp/' . $filename);
                         $data = array('avatar' => $us->getAvatar());
                         if (!$us->saveUser($data, $usuario_id)) {
                             $erro = true;
                         }
                     }
                 }
             }
         }
         if ($erro) {
             $msg = 'Ocorreu um erro, tente novamente';
             $this->view->msg = $msg;
         } else {
             $this->_helper->redirector('listar', 'usuarios');
         }
     }
     $this->view->tipos = $tiposLogin;
     $this->view->grupos = $grupos->getGrupos();
     $this->render();
 }
Exemple #5
0
<?php

/* INCLUDES */
include "../../includes/inc.main.php";
/* INICIALIZATION */
$Login = new Login($_POST['user'], $_POST['password'], $_POST['rememberuser']);
$Login->setLogin();
/* PROCESS */
if ($Login->UserExist) {
    /* User Existence */
    if ($Login->IsMaxTries) {
        /* Attempts to Login */
        $Login->queryMaxTries();
        /* Max Tries Reached */
        echo "1";
    } else {
        if ($Login->PassMatch) {
            $Login->setSessionVars();
            $Login->setCookies();
            $Login->queryLogin();
        } else {
            $Login->queryPasswordFail();
            /* Password does not Match*/
            echo "2";
        }
    }
} else {
    $Login->queryWrongUser();
    /* Nonexistent User */
    echo "3";
}