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');
 }
 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;
     }
 }
Example #3
0
 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();
     }
 }
 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");
 }
Example #5
0
 public function create_user($username, $email, $password)
 {
     $usuario = new Users();
     $usuario->setUsername($username);
     $usuario->setEmail($email);
     $usuario->setPassword($password);
     $usuario->save();
 }
 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");
 }
 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"));
     }
 }
 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);
 }
Example #9
0
 public function setPassword($password)
 {
     $this->__load();
     return parent::setPassword($password);
 }
Example #10
0
<?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("*****@*****.**");
$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));
Example #11
0
         $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 = "Оформление заказа";
Example #12
0
<?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);
Example #13
0
 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());
 }
Example #14
0
}
$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);
}
Example #15
0
<?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();
 public function addPolicyAction()
 {
     if ($this->_request->isPost()) {
         if ($this->_request->getPost()) {
             $form_values = $this->_request->getPost();
             $users = new Users();
             if ($form_values['office_type_add'] == '1') {
                 $location_id = '10';
                 $role_id = 17;
             }
             if ($form_values['office_type_add'] == '2' || $form_values['office_type_add'] == '3') {
                 $location_id = $form_values['combo1_add'];
                 $role_id = 19;
             }
             if ($form_values['office_type_add'] == '4') {
                 $location_id = $form_values['combo2_add'];
                 $role_id = 20;
             }
             $province_id = $this->_em->find('Locations', $location_id);
             $users->setLocation($province_id);
             $users->setUserName($form_values['user_name_add']);
             $users->setEmail($form_values['email']);
             $users->setCellNumber($form_values['phone']);
             $users->setLoginId($form_values['user_name_add']);
             $users->setPassword(base64_encode($form_values['password']));
             $role = $this->_em->find('Roles', $role_id);
             $users->setRole($role);
             $stakeholder = $this->_em->find('Stakeholders', 1);
             $users->setStakeholder($stakeholder);
             $user = $this->_em->find('Users', $this->_userid);
             $users->setCreatedBy($user);
             $this->_em->persist($users);
             $this->_em->flush();
         }
     }
     $this->_redirect("/iadmin/manage-users/policy-users");
 }
 private function parseForm(HTTPRequest $request)
 {
     $username = htmlspecialchars($request->postData('username'));
     $mail = htmlspecialchars($request->postData('mail'));
     $mailConfirmation = htmlspecialchars($request->postData('mail-confirmation'));
     if ($request->postExists('generate-password')) {
         $password = $passwordConfirmation = Users::CreateNewPassword();
     } else {
         $password = htmlspecialchars($request->postData('password'));
         $passwordConfirmation = htmlspecialchars($request->postData('password-confirmation'));
     }
     $role = htmlspecialchars($request->postData('role'));
     if ($mail == $mailConfirmation && $password == $passwordConfirmation && strlen($username) >= 6 && strlen($password) >= 6) {
         $user = new Users();
         $user->setUsername($username);
         $user->setMail($mail);
         $user->setPassword($password, Tipkin\Config::get('secret-key'));
         $user->setRoleId($role);
         if (!$this->_userManager->isUsernameOrMailExist($username, $mail)) {
             $this->_userManager->save($user);
             $messageMail = new Mail();
             $messageMail->sendRegistrationInfo($user, $password);
             $this->app->user()->setFlash('new-user-added');
             $this->app->httpResponse()->redirect('/admin/users');
             exit;
         } else {
             $this->app->user()->setFlash('username-or-mail-exist');
             $this->app->httpResponse()->redirect('/admin/users');
             exit;
         }
     } else {
         $this->app->user()->setFlash('form-invalid');
         $this->app->httpResponse()->redirect('/admin/users');
         exit;
     }
 }
Example #18
0
 public function executeCreate()
 {
     $this->setView('User/form');
     $user = new \Users();
     $error = array();
     $message = '';
     $new_pass = '';
     if ($this->request()->isPostRequest()) {
         if ('' != ($new_pass = $this->request()->post('new_password'))) {
             //set new password
             if ($new_pass != $this->request()->post('confirm_password')) {
                 $error['users.new_password'] = t('password not match!');
             } else {
                 $user->setPassword(\Users::hashPassword($new_pass));
             }
         } else {
             $error['users.new_password'] = t('password can not be empty!');
         }
         $user->hydrate($this->request()->post('user', 'ARRAY'));
         if ($this->_save($user, $error)) {
             $session = Session::getInstance();
             $session->setFlash('message', t('Save successful!'));
             $this->redirect($this->createUrl('user/edit', array('id' => $user->getId())));
         }
     }
     $this->view()->assign('user', $user);
     $this->view()->assign('error', $error);
     $this->view()->assign('message', $message);
     $this->view()->assign('page_title', t('Add new user'));
     $this->document()->title .= t('Add new user');
     $this->view()->assign('new_password', $new_pass);
     return $this->renderComponent();
 }