コード例 #1
0
 public function edit($args)
 {
     if ($_POST) {
         $filter = new Validations();
         $pass = new Password();
         $_POST["password"] = $filter->sanitizeText($_POST["password"]);
         $_POST["password"] = $pass->getPassword($_POST["password"]);
         if ($this->db->update("usuarios", $_POST)) {
             $this->redirect(array("controller" => "usuarios"));
         } else {
             $this->redirect(array("controller" => "usuarios", "action" => "edit"));
         }
     }
     $usuario = $this->db->find("usuarios", "first", array("conditions" => "usuarios.id=" . $args[0]));
     $this->set("usuario", $usuario);
 }
コード例 #2
0
 /**
  * Metodo de actualizar el usuario, parte del controlador 
  */
 public function edit($id = NULL)
 {
     if ($_POST) {
         if (!empty($_POST["pass"])) {
             $pass = new Password();
             $_POST["password"] = $pass->getPassword($_POST["pass"]);
         }
         if ($this->update("usuarios", $_POST)) {
             $this->redirect(array("controller" => "usuarios", "action" => "index"));
         } else {
             $this->redirect(array("controller" => "usuarios", "action" => "edit/" . $_POST["id"]));
         }
     } else {
         $this->_view->titulo = "Editar usuario";
         $this->_view->usuario = $this->find("usuarios", "first", array("conditions" => "id=" . $id));
         $this->_view->renderizar("edit");
     }
 }
コード例 #3
0
 public function edit($id = null)
 {
     if ($_POST) {
         $filter = new Validations();
         $pass = new Password();
         $_POST["password"] = $filter->sanitizeText($_POST["password"]);
         $_POST["password"] = $pass->getPassword($_POST["password"]);
         if ($this->User->update("users", $_POST)) {
             $this->redirect(array("controller" => "users", "action" => "index"));
         } else {
             $this->redirect(array("controller" => "users", "action" => "edit"));
         }
     }
     $user = $this->User->find("users", "first", array("conditions" => "users.id={$id}"));
     $this->set("user", $user);
     //$groups = $this->User->find("groups", "all");
     //$this->set("groups", $groups);
 }
コード例 #4
0
 public function edit($id = null)
 {
     if ($_POST) {
         if (!empty($_POST['pass'])) {
             $pass = new Password();
             $_POST['password'] = $pass->getPassword($_POST['pass']);
         }
         if ($this->db->update("usuarios", $_POST)) {
             $this->redirect(array('controller' => 'usuarios', 'action' => 'index'));
         } else {
             $this->redirect(array('controller' => 'usuarios', 'action' => 'edit'));
         }
     } else {
         $this->_view->titulo = "Editar usuario";
         $this->_view->usuario = $this->db->find('usuarios', 'first', array('conditions' => 'id=' . $id));
         $this->_view->renderizar('edit');
     }
 }
コード例 #5
0
 public function edit($id = null)
 {
     /**
      * edit function to edit users
      * @param  string $id contains the id of the row
      * @return void
      */
     if ($_POST) {
         if (!empty($_POST['pass'])) {
             $pass = new Password();
             $_POST['password'] = $pass->getPassword($_POST['pass']);
         }
         if ($this->db->update("usuarios", $_POST)) {
             $this->redirect(array('controller' => 'usuarios', 'action' => 'index'));
         } else {
             $this->redirect(array('controller' => 'usuarios', 'action' => 'edit'));
         }
     } else {
         $this->_view->titulo = "Editar usuario";
         $this->_view->usuario = $this->db->find('usuarios', 'first', array('conditions' => 'id=' . $id));
         $this->_view->renderizar('edit');
     }
 }
コード例 #6
0
 /**
  * add este metodo es para añadir un usuario
  */
 public function add()
 {
     $pass = new Password();
     if ($_POST) {
         //se invvoca al metodo para incriptar
         $cryp = $pass->getPassword($_POST['password']);
         //se elimina el password
         unset($_POST['password']);
         //se agrega el password ya encriptado
         $_POST = $_POST + array('password' => $cryp);
         # code...
     }
     if ($_POST) {
         if ($this->db->save('usuarios', $_POST)) {
             $this->redirect(array('controller' => 'usuarios', 'action' => 'index'));
         } else {
             $this->redirect(array('controller' => 'usuarios', 'action' => 'add'));
         }
     } else {
         $this->_view->titulo = "Agregar usuarios";
         $this->_view->renderizar = "add";
     }
     $this->_view->renderizar('add');
 }
コード例 #7
0
ファイル: User.php プロジェクト: habtom/uas
 public function save(PropelPDO $con = null)
 {
     if (!$this->getId()) {
         $this->setUid(UserPeer::getMaxUid() + 1);
         $password = new Password();
         $this->generated_password = $password->getPassword();
         $this->setNtPassword($password->getNtHash());
         $this->setUnixPassword($password->getNtHash());
         $this->setCryptPassword($password->getCryptHash());
         $this->setLmPassword($password->getLmHash());
     }
     if (!$this->getDomainnameId()) {
         // get the default domainname
         $domainname = DomainnamePeer::getDefaultDomainname();
         $this->setDomainnameId($domainname->getId());
     }
     if (!$this->getLogin()) {
         $this->generateLogin();
     }
     if (!$this->getEmailLocalPart()) {
         $this->generateEmailLocalPart();
     }
     return parent::save();
 }
コード例 #8
0
        }
    }
    //PHP >= 5.5.0
    public static function getPassword($password)
    {
        $option = array("cost" => 7);
        $hash = password_hash($password, PASSWORD_BCRYPT, $option);
        return $hash;
    }
    public static function passwordVerify($pass1, $pass2)
    {
        if (password_verify($pass1, $pass2)) {
            return true;
        }
        return false;
    }
}
$verificador = new Password();
$password1 = "12345";
$password2 = 12345;
echo md5($password1);
echo "<br>";
$hash = Password::getPassword($password1);
echo $hash;
echo "<br>";
echo "<br>";
if (Password::passwordVerify($password2, $hash)) {
    echo "Contraseñas validas";
} else {
    echo "Contraseñas invalidas";
}
コード例 #9
0
ファイル: uasTest.php プロジェクト: rgevaert/uas
<?php

// test/unit/uasTest.php
require_once dirname(__FILE__) . '/../bootstrap/unit.php';
require_once dirname(__FILE__) . '/../../lib/Password.class.php';
$t = new lime_test(5, new lime_output_color());
$pass = new Password();
$p = $pass->getPassword();
$t->is(strlen($p), 8);
preg_match_all('/[A-Z]/', $p, $cap_letter_match);
preg_match_all('/[a-z]/', $p, $small_letter_match);
preg_match_all('/[0-9]/', $p, $number_match);
preg_match_all('/[&\\$@#\\)\\(\\[\\]\\?><!]/', $p, $special_char_match);
$t->is(count($cap_letter_match[0]), 2);
$t->is(count($small_letter_match[0]), 2);
$t->is(count($number_match[0]), 2);
$t->is(count($special_char_match[0]), 2);