本文整理汇总了PHP中Users::setPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::setPassword方法的具体用法?PHP Users::setPassword怎么用?PHP Users::setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::setPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitAction
public function submitAction()
{
if (!$this->getRequest()->isPost()) {
return $this->_forward('index');
}
$form = $this->getForm();
// Validate the form itself
if (!$form->isValid($_POST)) {
$this->view->form = $form;
return $this->render('index');
}
// Get the form data
$values = $form->getValues();
$email = $values['email'];
// Find the user
$users = new Users();
if (!($user = $users->getUserFromEmail($email))) {
$this->view->failedRecovery = true;
return $this->_forward('index');
}
// Change the password
$password = Stuffpress_Token::create(8);
$users->setPassword($user->id, $password);
// Send the user an email with the new password
Stuffpress_Emails::sendRecoveryEmail($email, $user->username, $password);
// Done !
$this->view->email = $email;
$this->render('success');
}
示例2: create
public function create($login, $pass)
{
$user = new Users();
$valid = $user->setLogin($login);
if ($valid === true) {
$valid = $user->setPassword($pass);
if ($valid === true) {
$login = mysqli_real_escape_string($this->database, $user->getLogin());
$pass = mysqli_real_escape_string($this->database, $user->getHash());
$query = "INSERT INTO users (login, pass)\n\t\t\t\t\tVALUES ('" . $login . "', '" . $pass . "')";
$result = mysqli_query($this->database, $query);
if ($result) {
$id = mysqli_insert_id($this->database);
if ($id) {
return $this->findById($id);
} else {
return "Erreur serveur.";
}
} else {
return mysqli_error();
}
} else {
return $valid;
}
} else {
return $valid;
}
}
示例3: login
public function login($post)
{
$errors = array();
$user = new Users();
$user->exchangeArray($post);
$username = trim($user->getUsername());
$user->setUsername($username);
$password = trim($user->getPassword());
$user->setPassword($password);
$_SESSION['id'] = $this->getLogged_user_id($username);
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
if (empty($username)) {
$errors['username'] = "Моля, въведете потребителско име!";
}
if (empty($password)) {
$errors['password'] = "Моля, въведете парола!";
}
if ($this->select($user) == false && !isset($errors['username'])) {
$errors['username'] = "Въведените потребителско име и/или парола са невалидни!";
} elseif ($this->select($user) == true) {
$_SESSION['isLogged'] = true;
}
if (count($errors) > 0) {
return $errors;
} else {
return $errors = array();
}
}
示例4: addAction
public function addAction()
{
$form = new Form_Cadmin_User();
if ($this->_request->isPost()) {
if ($form->isValid($this->_request->getPost())) {
$user = new Users();
$user->setLoginId($form->login_id->getValue());
$user->setUserName($form->login_id->getValue());
$role_id = $this->_em->find('Roles', $form->role->getValue());
$user->setRole($role_id);
$user->setEmail($form->email->getValue());
$user->setCellNumber($form->phone->getValue());
$user->setPassword(base64_encode($form->password->getValue()));
$created_by = $this->_em->find('Users', $this->_userid);
$user->setCreatedBy($created_by);
$user->setLoggedAt(new \DateTime(date("0000-00-00")));
$stakeholder = $this->_em->find('Stakeholders', 1);
$user->setStakeholder($stakeholder);
$this->_em->persist($user);
$this->_em->flush();
$user_wh = new WarehouseUsers();
$user_wh->setUser($user);
$warehouse_id = $this->_em->find('Warehouses', $this->_request->getPost('warehouse'));
$user_wh->setWarehouse($warehouse_id);
$user_wh->setIsDefault(1);
$this->_em->persist($user_wh);
$this->_em->flush();
}
}
$this->_redirect("/cadmin/manage-users");
}
示例5: create_user
public function create_user($username, $email, $password)
{
$usuario = new Users();
$usuario->setUsername($username);
$usuario->setEmail($email);
$usuario->setPassword($password);
$usuario->save();
}
示例6: updateAction
public function updateAction()
{
//Disable view
$this->view->disable();
//As usual, catch and process posted data
if ($this->request->isPost() && in_array($action = $this->request->getPost("action"), array("Add", "Update"))) {
if (empty($company = ucfirst(htmlspecialchars($this->request->getPost("company_name", "trim"))))) {
$this->flashSession->error("Nama perusahaan belum diisi. Mohon isi nama perusahaan dan ulangi proses kembali!");
return $this->response->redirect("responden");
}
$email = htmlspecialchars($this->request->getPost("email", "trim"));
if ($action == "Add") {
$login_name = htmlspecialchars($this->request->getPost("username", "trim"));
if (empty($login_name)) {
$this->flashSession->error("Username belum diisi. Mohon isi kolom username dan ulangi proses kembali!");
return $this->response->redirect("responden");
}
$name = ucfirst(htmlspecialchars($this->request->getPost("first_name", "trim")));
if (empty($name)) {
$this->flashSession->error("Nama Depan belum diisi. Mohon isi kolom Nama Depan dan ulangi proses kembali!");
return $this->response->redirect("responden");
}
if (!empty($this->request->getPost("last_name", "trim"))) {
$name = $name . " " . ucfirst(htmlspecialchars($this->request->getPost("last_name", "trim")));
}
$user = new Users();
$user->setLoginName($login_name)->setName($name)->setCompanyName($company)->setEmail($email);
//Set the default password
$user->setPassword($this->security->hash(self::DEFAULT_PASSWORD));
//Set role_id to Respondent's role id
$user->setIdRole(Roles::findFirstByName("Respondent")->getIdRole());
if (!$user->save()) {
$this->flashSession->error("Fatal Error! Error occured while adding new user record");
foreach ($user->getMessages() as $err) {
$this->flashSession->error($err);
}
return $this->response->redirect("responden");
}
}
$this->flashSession->success("Data telah berhasil disimpan ke database.");
}
return $this->response->redirect("responden");
}
示例7: registerAction
public function registerAction()
{
parent::initalize();
//echo '<link rel=stylesheet href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />';
$user = new Users();
if ($this->request0 > isPost() && $this->request->getPost('password') == $this->request->getPost('confirm')) {
$user->name = $this->request->getPost('name');
$user->email = $this->request->getPost('email');
$user->setPassword($this->request->getPost('password'));
$success = $user->save();
if ($success) {
echo $this->flash->success("Thanks for registering {$user->email}");
} else {
echo $this->flash->error("error");
foreach ($user->getMessages() as $msg) {
echo $this->flash->error($msg);
}
}
$this->dispatcher->forward(array("controller" => "signup", "action" => "index"));
}
}
示例8: submitAction
public function submitAction()
{
// Validate the form and extract the values
if (!$this->getRequest()->isPost()) {
return $this->_helper->json->sendJson(true);
}
$form = $this->getForm();
if (!$form->isValid($_POST)) {
return $this->_helper->json->sendJson($form->getErrorArray());
}
// Get the values and proceed
$values = $form->getValues();
$password = $values['password'];
$confirm = $values['confirm'];
if (strcmp($password, $confirm)) {
return $this->_helper->json->sendJson(array("Passwords do not match."));
}
// Save the new values
$users = new Users();
$users->setPassword($this->_application->user->id, $password);
// Ok
return $this->_helper->json->sendJson(false);
}
示例9: setPassword
public function setPassword($password)
{
$this->__load();
return parent::setPassword($password);
}
示例10: array
<?php
spl_autoload_register(function ($class) {
include "library/" . $class . ".php";
});
$connection = array("dbserver" => "mysql", "host" => 'localhost', "dbname" => "loft", "port" => 3306, "user" => "dake", "password" => "boromir");
$user = new Users($connection);
$user->setName("Иван");
$user->setLastname("Иванов");
$user->setBirthday("20.09.1985");
$user->setEmail("domain@mail.ru");
$user->setPassword("asdasd");
$user->setIsActive(1);
$user->setRegDate("10.09.2015");
$user->setLastUpdate("11.09.2015");
//TODO: проеобразовать запрашиваемые значения в utf-8
//$res = $user->findBy(array("is_active"=>"0", "name"=>("Бернар")));
//var_dump($res);
$user->update(array("id" => "6", "is_active" => "4"), array("lastname" => "Кох", "name" => "David", "is_active" => 1));
示例11: header
$query = "SELECT id,login FROM fw_users WHERE mail = '{$email}' ";
$result = $db->get_single($query);
if (!empty($result['id'])) {
$return['status'] = 'success';
$return['data'] = $result;
}
}
header("Content-Type:text/json;charset:utf8;");
echo json_encode($return);
die;
break;
case @$url[$n] == 'step1' && $url[$n - 1] == 'basket':
//идет авторизация на 1 шаге
if (isset($_POST['submit_login'])) {
$users->setEmail($_POST['email']);
$users->setPassword($_POST['password']);
if ($users->get_login()) {
header("Location: " . BASE_URL . '/catalog/basket/step1/');
die;
} else {
$smarty->assign('error_auth_message', 'Неверно введен логин или пароль');
}
}
if ($user_id = $users->is_auth_user()) {
$user = $users->get_user($user_id);
$smarty->assign('user', $user);
}
$page_found = true;
$navigation[] = array("url" => 'basket', "title" => 'Моя корзина');
$navigation[] = array("url" => 'step1', "title" => 'Оформление заказа');
$title = "Оформление заказа";
示例12: Users
<?php
require_once "../config.inc.php";
session_start();
$first = $_REQUEST['first'];
$last = $_REQUEST['last'];
$email = $_REQUEST['email'];
$creator_id = $_REQUEST['creator_id'];
$user_type_id = $_REQUEST['user_type_id'];
$active = 0;
print_r($_FILES);
print_r($_REQUEST);
$file = $_FILES['file']['name'];
$temp_file = $_FILES['file']['tmp_name'];
$token = bin2hex(openssl_random_pseudo_bytes(3));
$data['creator_id'] = $creator_id;
$data['user_type_id'] = $user_type_id;
$data['first'] = $first;
$data['last'] = $last;
$data['email'] = $email;
$data['active'] = $active;
$data['avatar'] = $file;
$data['hasher'] = $token;
$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();
$u = new Users('member', BASE_DOMAIN);
$data['password'] = $u->setPassword($token);
//setPassword($password)
$update = $u->addUser($data);
$upload_dir = '/avatars/';
$upload_file = $u->uploader($file, $temp_file, $upload_dir);
示例13: executeLdap
public function executeLdap(sfWebRequest $request)
{
$this->form = new LdapLoginForm();
if ($request->isMethod('post')) {
$this->form->bind($request->getParameter($this->form->getName()));
if ($this->form->isValid()) {
$ldap = new ldapLogin();
$user_attr = $ldap->doLdapLogin($this->form['user']->getValue(), $this->form['password']->getValue());
if ($user_attr['status'] == true) {
$userName = $this->form['user']->getValue();
$userEmail = $this->form['user']->getValue() . '@localhost.com';
if (strlen($user_attr['email']) > 0) {
$userEmail = $user_attr['email'];
}
if (strlen($user_attr['name']) > 0) {
$userName = $user_attr['name'];
}
$q = Doctrine_Core::getTable('Users')->createQuery()->addWhere('email=?', $userEmail);
if (!($user = $q->fetchOne())) {
$user = new Users();
$user->setUsersGroupId(sfConfig::get('app_ldap_default_user_group'));
$user->setName($userName);
$user->setEmail($userEmail);
$user->setPassword(md5($this->form['password']->getValue()));
$user->setActive(1);
$user->setCulture(sfConfig::get('sf_default_culture'));
$user->save();
} else {
if ($user->getActive() != 1) {
$this->getUser()->setFlash('userNotices', I18NText::__('Your account is not active'));
$this->redirect('login/ldap');
}
}
$this->doUserLogin($user, $request);
} else {
$this->getUser()->setFlash('userNotices', t::__($user_attr['msg']));
$this->redirect('login/ldap');
}
}
}
app::setPageTitle('LDAP Login', $this->getResponse());
}
示例14:
}
$active = 1;
$token = bin2hex(openssl_random_pseudo_bytes(3));
$file = $_FILES['file']['name'];
$temp_file = $_FILES['file']['tmp_name'];
//$data['id'] = $my_id;
$data['first'] = $first;
$data['last'] = $last;
$data['email'] = $email;
$data['active'] = $active;
$data['hasher'] = $token;
if (is_null($password)) {
//do nothing
} else {
//echo "i'm setting the password ".$password." ";
$data['password'] = $u->setPassword($password);
//otherwise don't touch password
$data['pwd_reset_code'] = "";
$u->update_password($data, $my_id);
}
if ($file === "") {
//do nothing
$data['avatar'] = $avatar_name;
$update = $u->update_setting($data, $my_id);
} else {
$data['avatar'] = $file;
echo "adding new avatar";
$update = $u->update_setting($data, $my_id);
$upload_dir = '/avatars/';
$upload_file = $u->uploader($file, $temp_file, $upload_dir);
}
示例15: Query
<?php
require_once 'autoloader.php';
$query = new Query();
$query->orderBy('id', 'DESC');
$query->limit(2, 4);
$user = $query->isEntity('Users');
var_dump($user);
$user = new Users();
$user->setPseudo('Luke Skywalker');
$user->setAge('26');
$user->setPassword('LoveMySister');
$user->save();