public function actionRegister()
 {
     $formModel = new Registration();
     //$this->performAjaxValidation($formModel);
     if (isset($_POST['Registration'])) {
         $formModel->email = $_POST['Registration']['email'];
         $formModel->username = $_POST['Registration']['username'];
         $formModel->password = $_POST['Registration']['password'];
         $formModel->password_repeat = $_POST['Registration']['password_repeat'];
         $formModel->verification_code = $_POST['Registration']['verification_code'];
         if ($formModel->validate()) {
             $model = new User();
             if ($model->insert(CassandraUtil::uuid1(), array('email' => $_POST['Registration']['email'], 'username' => $_POST['Registration']['username'], 'password' => User::encryptPassword($_POST['Registration']['password']), 'active' => false, 'blocked' => false)) === true) {
                 echo 'Model email ' . $formModel->email . ' && username ' . $formModel->username;
                 if (!User::sendRegisterVerification($formModel->email, $formModel->username)) {
                     echo 'failed';
                 } else {
                     echo 'done';
                 }
                 die;
                 //$this->redirect(array('user/profile'));
             }
         }
     }
     $this->render('register', array('model' => $formModel));
 }
Example #2
0
function add_user()
{
    global $sql, $cfg;
    $act = true;
    $name = $sql->quote(htmlspecialchars($_POST['name']));
    $fon = $sql->quote(htmlspecialchars($_POST['fon']));
    $email = $sql->quote(htmlspecialchars($_POST['email']));
    $passhash = sha1($_POST['password']);
    $passhash = $sql->quote($passhash);
    $user = new User($name);
    $user->fon = $fon;
    $user->email = $email;
    $user->passhash = $passhash;
    $qry = sprintf("select uid from %susers where name=%s;", $cfg['dbprefix'], $name);
    if ($sql->query($qry)->fetch()) {
        $alerts[] = "Dieser Name ist schon Belegt.";
        $act = false;
    }
    if ($act) {
        if ($user->insert()) {
            $notifs[] = "User hinzugefuegt.";
        } else {
            $alerts[] = "Unbekannter Fehler, bitte Jan Bescheid geben!";
        }
    }
}
 private function processILSUser($info)
 {
     require_once ROOT_DIR . "/services/MyResearch/lib/User.php";
     $user = new User();
     //Marmot make sure we are using the username which is the
     //unique patron ID in Millennium.
     $user->username = $info['username'];
     if ($user->find(true)) {
         $insert = false;
     } else {
         $insert = true;
     }
     $user->password = $info['cat_password'];
     $user->firstname = $info['firstname'] == null ? " " : $info['firstname'];
     $user->lastname = $info['lastname'] == null ? " " : $info['lastname'];
     $user->cat_username = $info['cat_username'] == null ? " " : $info['cat_username'];
     $user->cat_password = $info['cat_password'] == null ? " " : $info['cat_password'];
     $user->email = $info['email'] == null ? " " : $info['email'];
     $user->major = $info['major'] == null ? " " : $info['major'];
     $user->college = $info['college'] == null ? " " : $info['college'];
     $user->patronType = $info['patronType'] == null ? " " : $info['patronType'];
     $user->web_note = $info['web_note'] == null ? " " : $info['web_note'];
     if ($insert) {
         $user->created = date('Y-m-d');
         $user->insert();
     } else {
         $user->update();
     }
     return $user;
 }
Example #4
0
 public function insert($datas = null)
 {
     $id = parent::insert($datas);
     $this->load->model('memberspace/right');
     $this->user->addToGroup('administrators', $id);
     return $id;
 }
Example #5
0
 public function signup()
 {
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'GET':
             if (isset($_SESSION['user'])) {
                 show_message('message success', "You're already connected as " . $_SESSION['user']);
                 include 'views/home.php';
             } else {
                 include 'views/signup.php';
             }
             break;
         case 'POST':
             if (isset($_POST['login']) && isset($_POST['password']) && isset($_POST['password_check'])) {
                 $exist = User::exist_login($_POST['login']);
                 if (!$exist) {
                     if ($_POST['password'] == $_POST['password_check']) {
                         User::insert(htmlspecialchars($_POST['login']), sha1($_POST['password']), htmlspecialchars($_POST['email']));
                         show_message('message success', "Signup of  " . $_POST['login'] . ' !');
                         include 'views/signin.php';
                     } else {
                         show_message('message error', "Not same password");
                         include 'views/signup.php';
                     }
                 } else {
                     show_message('message error', "Enter other information");
                     include 'views/signup.php';
                 }
             } else {
                 show_message('message error', "Incomplete data!");
                 include 'views/signup.php';
             }
             break;
     }
 }
Example #6
0
	public function addUser($mysql, $username, $password) {
		$user = new User();
		$user->read($username, $password);
			switch($user->insert($mysql)) {
				case User::DATABASE_ERROR :
				{
					echo "<p>A Database error has occured.</p>";
					return;
				}
				case User::INVALID_DATA :
				{
					echo "<p>Invalid operation requested.</p>";
					return;
				}
				case User::INSERT_SUCCESS : 
				{
					echo "<p>User added successfully.</p>";
					break;
				}
				case User::USERNAME_TAKEN :
				{
					echo "Username alraedy Exists.";
					break;
				}
				default :
					break;
			}
	}
Example #7
0
 public function signupAction()
 {
     $form = $this->_getRegistrationForm();
     if ($form->isValid($this->getRequest()->getPost())) {
         $values = $form->getValues();
         require_once APPLICATION_PATH . '/model/User.php';
         $table = new User();
         $data = array('username' => $values['username'], 'password' => sha1($values['password']), 'first_name' => $values['first_name'], 'last_name' => $values['last_name'], 'live_town' => $values['live_town'], 'work_town' => $values['work_town']);
         if (!empty($values['phone'])) {
             $data['phone'] = $values['phone'];
         }
         if (!empty($values['email'])) {
             $data['email'] = $values['email'];
         }
         if (!empty($values['licence'])) {
             $data['licence'] = true;
         }
         if (!empty($values['own_car'])) {
             $data['own_car'] = true;
         }
         $table->insert($data);
         $this->view->successful = true;
     } else {
         $this->view->form = $form;
     }
 }
 public function store()
 {
     if (!Input::has('email', 'password', 'confirmPassword')) {
         $this->failure("Must fill in the values");
     }
     if (Input::get('password') != Input::get('confirmPassword')) {
         $this->failure("PASSWORDS NOT THE SAME");
     }
     $rules = array('email' => 'unique:users,email');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $this->failure('That email address is already registered. You sure you don\'t have an account?');
     }
     if (!filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL)) {
         $this->failure("username must be an email");
     }
     $verificationCode = md5(time());
     User::insert(array('email' => Input::get('email'), 'password' => Hash::make(Input::get('password')), 'verification' => $verificationCode));
     Image::insert(array('email' => Input::get('email'), 'image' => ''));
     Notes::insert(array('email' => Input::get('email'), 'notes' => ''));
     TBD::insert(array('email' => Input::get('email'), 'tbd' => ''));
     Links::insert(array('email' => Input::get('email'), 'links' => ''));
     Mail::send('emails.emailMessage', array('code' => $verificationCode, 'email' => Input::get('email')), function ($message) {
         $message->to('*****@*****.**', 'Jan Ycasas')->subject('Welcome!');
     });
     echo "Go Log In";
     return Redirect::to('/');
 }
Example #9
0
function groupadd_POST(Web $w)
{
    $user = new User($w);
    $user->login = $_REQUEST['title'];
    $user->is_group = 1;
    $user->insert();
    $w->msg("New group added!", "/admin/groups");
}
Example #10
0
 public function run()
 {
     $users = array(['username' => 'owner', 'email' => '*****@*****.**', 'rights' => 1]);
     $users = array_map(function ($user) {
         $user['password'] = Hash::make('changeme');
         return $user;
     }, $users);
     User::insert($users);
 }
Example #11
0
 /**
  * @depends testInit
  */
 public function testInsertUser()
 {
     $user = new User();
     $user->name = 'demo';
     $user->password = md5('demo');
     $user->insert();
     $this->assertGreaterThan(0, $user->id);
     return $user;
 }
Example #12
0
 public function run()
 {
     $faker = Faker::create();
     $users = [];
     $password = Hash::make($faker->word());
     foreach (range(1, 10) as $index) {
         $users[] = ['username' => $faker->userName(), 'email' => $faker->email(), 'password' => $password, 'api_key' => $faker->md5(), 'api_token' => $faker->sha1(), 'domain' => $faker->domainName()];
     }
     User::insert($users);
 }
 public function indexAction()
 {
     //TODO: Überprüfung auf Passwort und unique E-Mail auch in EditController
     $namespace = new Zend_Session_Namespace('user');
     if ($this->getRequest()->isPost() and $this->form->isValid($this->getRequest()->getParams())) {
         if ($this->form->getValue('Token') == $namespace->Token) {
             //get parameters for test of unique username
             $userTable = new User();
             $tableRow = User::COL_USERNAME;
             $value = $this->getRequest()->getParam(User::COL_USERNAME);
             if ($this->getRequest()->getParam(User::COL_PASSWORD) != $this->getRequest()->getParam(User_Form_Edit::PASSWORD_CLONE)) {
                 $element = $this->form->getElement(User_Form_Edit::PASSWORD_CLONE);
                 $element->addError("Error: Your password and the repeating don't match.");
                 $this->form->markAsError();
                 return $this->render('index');
             } elseif (Default_SimpleQuery::isValueInTableColumn($value, $userTable, $tableRow, 'string')) {
                 $element = $this->form->getElement(User::COL_USERNAME);
                 $element->addError("Error: This username is already used.");
                 $this->form->markAsError();
                 return $this->render('index');
             } else {
                 try {
                     //values checked, insert
                     $guid = Ble422_Guid::getGuid();
                     $userTable = new User();
                     $userTable->getAdapter()->beginTransaction();
                     $userId = $userTable->insert(array(User::COL_USERNAME => $this->form->getValue(User::COL_USERNAME), User::COL_FIRSTNAME => $this->form->getValue(User::COL_FIRSTNAME), User::COL_LASTNAME => $this->form->getValue(User::COL_LASTNAME), User::COL_PASSWORD => "{SHA}" . base64_encode(pack("H*", sha1($this->form->getValue(User::COL_PASSWORD)))), User::COL_EMAIL => $this->form->getValue(User::COL_USERNAME), User::COL_INSTITUTION => $this->form->getValue(User::COL_INSTITUTION), User::COL_STREET => $this->form->getValue(User::COL_STREET), User::COL_COUNTRY => $this->form->getValue(User::COL_COUNTRY), User::COL_PHONE => $this->form->getValue(User::COL_PHONE), User::COL_FAX => $this->form->getValue(User::COL_FAX), User::COL_CITY => $this->form->getValue(User::COL_CITY), User::COL_GUID => $guid, User::COL_ACTIVE => 0));
                     $toAdress = $this->form->getValue(User::COL_USERNAME);
                     $bodyText = "Please click this link to confirm your new account:\r\n" . Zend_Registry::get('APP_HOST') . '/default/registeruser/confirm/' . User::COL_GUID . '/' . $guid;
                     $mail = new Default_Mail($toAdress, 'WebGR register user message', $bodyText);
                     $mail->send();
                     $userTable->getAdapter()->commit();
                     $namespace->Token = '';
                     $this->redirectTo('success');
                 } catch (Exception $e) {
                     $userTable->getAdapter()->rollBack();
                     throw new Exception('error at register a new user: '******'success');
         }
     } else {
         //no post or some element(s) not valid
         //$this->form->setAction(Zend_Controller_Front::getInstance()->getBaseUrl()."/user/new");
         if ($this->form->getValue('Token') == null) {
             $guid = new Ble422_Guid();
             $namespace->Token = $guid->__toString();
             $this->form->getElement('Token')->setValue($guid->__toString());
         }
     }
 }
    /**
     * Exibe o form para cadastro de usuário.
     *
     * Registra um novo usuário quando a requisição for POST
     * Caso o nome ou o email informado não forem únicos na tabela, passaremos
     * uma mensagem de erro para a view e não registramos este usuário.
     *
     * @return boolean|void
     */
    public function createAction()
    {
        $form = new Application_Form_User();
        $form->setAction('/users/create');

        if ( $this->_request->isPost() )
        {
            $data = array(
                'name'  => $this->_request->getPost('name'),
                'email' => $this->_request->getPost('email')
            );

            if ( $form->isValid($data) )
            {
                $this->_model->insert($data);
                $this->view->message = "Usu&aacute;rio cadastrado com sucesso.";
            }
        }

        $this->view->form = $form;
    }
Example #15
0
 public function run()
 {
     $exist = DB::table('users')->where('username', 'owner')->first();
     if (!$exist) {
         $users = array(['username' => 'owner', 'email' => '*****@*****.**', 'rights' => 1]);
         $users = array_map(function ($user) {
             $user['password'] = Hash::make('changeme');
             return $user;
         }, $users);
         User::insert($users);
     }
 }
Example #16
0
function user_post($where = array())
{
    $user = new User("t_users");
    $result = $user->select();
    foreach ($result as $u) {
        if ($where['email'] == $u['email']) {
            return array("fail" => "This account already exists");
        }
    }
    $user->insert($where);
    return;
}
Example #17
0
 public function run()
 {
     if (Yii::app()->request->isAjaxRequest) {
         try {
             $name = Yii::app()->request->getParam('name');
             $mobile = Yii::app()->request->getParam('mobile');
             $code = Yii::app()->request->getParam('code');
             $email = Yii::app()->request->getParam('email');
             $password = Yii::app()->request->getParam('password');
             $_code = Yii::app()->session['regist_code' . $mobile];
             if ($_code && $_code == $code) {
                 $item = Yii::app()->db->createCommand('select * from user where mobile=' . $mobile . ' and status=0')->queryRow();
                 if (!$item) {
                     $user = new User();
                     $user->nickName = $name;
                     $user->mobile = $mobile;
                     $user->email = $email;
                     $user->status = 0;
                     if ($password) {
                         $user->password = md5($password);
                     }
                     $wechat = Yii::app()->session['wechat'];
                     if ($wechat) {
                         // $user->nickName = $wechat['nickname'];
                         $user->portrait = $wechat['headimgurl'];
                         $user->gender = $wechat['sex'];
                     }
                     $user->insert();
                     //消息系统初始化
                     EasemobHelper::initIM($user->id, array('username' => $user->id, 'password' => 'nakedim', 'nickname' => $name));
                     $user->isBindIM = 1;
                     $user->type = 3;
                     $user->save();
                     Yii::app()->session['user'] = $user;
                 } else {
                     Yii::log(print_r($item, 1), CLogger::LEVEL_ERROR, 'info');
                     Yii::app()->session['user'] = $item;
                 }
                 //如果用户注册过了,没付款不生成新的用户,读取数据库里的用户信息
                 // $identity = new UserIdentity();
                 // $identity->registAuth($user);
                 // $duration = Yii::app()->getComponent('session')->getTimeout();
                 // Yii::app()->user->login($identity, $duration);
                 echo CJSON::encode(array('code' => 200, 'message' => 'success'));
             } else {
                 echo CJSON::encode(array('code' => 500, 'message' => '验证码错误'));
             }
         } catch (CException $e) {
             Yii::log($e->getMessage(), CLogger::LEVEL_ERROR);
             echo CJSON::encode(array('code' => 500, 'message' => '注册失败'));
         }
     }
 }
Example #18
0
 public function verifyPasscode()
 {
     $user = new User();
     $deviceDetail = new DeviceDetails();
     $passVeri = new PasscodeVerification();
     $data = Input::all();
     $deviceDetail->insert($data);
     $passVeri->updateVerify($data['mobile_number']);
     $userDetail = $user->insert($data);
     $msg = "Account successfully created.";
     return $this->successMessageWithVar($msg, $userDetail, 'userDetails');
 }
Example #19
0
 public function run()
 {
     DB::table('personas')->delete();
     $contraseña = Hash::make('abcdef');
     $faker = Faker\Factory::create('es_VE');
     User::create(array('nombre' => 'Gabriel Bejarano', 'cedula' => 1034307256, 'email' => '*****@*****.**', 'password' => Hash::make('gab23gab'), 'residencia_id' => '2', 'admin' => '1'));
     User::create(array('nombre' => 'Usuario de Prueba', 'cedula' => 1000000, 'email' => '*****@*****.**', 'password' => Hash::make('residenciasonline'), 'residencia_id' => '1', 'admin' => '1', 'avatar' => 'https://cdn0.vox-cdn.com/images/verge/default-avatar.v9899025.gif'));
     for ($i = 0; $i < 200; $i++) {
         $users[] = array('nombre' => $faker->name, 'cedula' => rand(100000, 100000000), 'email' => $faker->email, 'password' => $contraseña, 'residencia_id' => rand(1, 100), 'admin' => '0');
     }
     User::insert($users);
     $this->command->info('Personas Table Seed!');
 }
Example #20
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     //var_dump($_POST);die;
     if (!isset($_SESSION['filemanager'])) {
         $_SESSION['filemanager'] = true;
     }
     $_SESSION['currentFolder'] = 'user/';
     $model = new User('create');
     $role = null;
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         //check valid roles
         $roleArray = array('Manager', 'Administrator', 'Super User');
         $role = Yii::app()->request->getPost('role');
         if (!in_array($role, $roleArray)) {
             throw new CHttpException(451, Yii::t('user', 'Roles is not a valid value.'));
         }
         //tuyen add
         Yii::app()->user->setFlash('error', Yii::t('user', 'Add user failed. Please try it later!'));
         //end tuyen add
         if ($model->validate()) {
             $transaction = Yii::app()->db->beginTransaction();
             try {
                 $model->registerd_date = date('Y-m-d H:i:s');
                 if (!empty($model->password)) {
                     $model->salt = Yii::app()->extraFunctions->randomString(32);
                     $model->password = Yii::app()->extraFunctions->encryptUserPassword($model->salt, $model->password);
                 }
                 $avatarArray = explode('/', $_POST['User']['avatar']);
                 $model->avatar = $avatarArray[count($avatarArray) - 1];
                 if ($model->insert()) {
                     //save role
                     Yii::import('application.modules.backend.controllers.AuthorizedController');
                     $t = new AuthorizedController($model->id);
                     if ($t->SaveRole($model->id, $role)) {
                         Yii::app()->user->setFlash('success', Yii::t('user', 'Add user successfully.'));
                         $transaction->commit();
                     } else {
                         Yii::app()->user->setFlash('error', Yii::t('user', 'Add user failed. Please try it later!'));
                         $transaction->rollback();
                     }
                 }
             } catch (Exception $ex) {
                 Yii::app()->user->setFlash('error', Yii::t('user', 'Add user failed. Please try it later!'));
                 $transaction->rollback();
             }
             $this->redirect(array('/' . backend . '/user/admin'));
         }
     }
     $this->render(strtolower($this->action->Id), array('model' => $model, 'role' => $role));
 }
Example #21
0
 public function display()
 {
     $userlist = new Template();
     $userlist->load("user_list");
     $userlist->assign_var("URL", $this->page->GetUrl());
     if (isset($_POST['insert'])) {
         $user = new User();
         $user->name = $_POST['name'];
         $user->role = $_POST['new_user_role'];
         $user->email = $_POST['email'];
         if (!$user->insert($_POST['password'])) {
             $userlist->assign_var("MSG", Language::DirectTranslateHtml("USER_NOT_CREATED"));
         }
     }
     if (isset($_GET['delete'])) {
         $user = new User();
         $user->id = $_GET['delete'];
         if (!$user->delete()) {
             $userlist->assign_var("MSG", Language::DirectTranslateHtml("USER_NOT_DELETED"));
         }
     }
     $userlist->assign_var("MSG", "");
     Cache::clear("tables", "userlist");
     $table = new Table();
     $id = new TableColumn("id", Language::DirectTranslate("ID"));
     $id->autoWidth = true;
     $name = new TableColumn("name", Language::DirectTranslate("NAME"));
     $role = new TableColumn("role", Language::DirectTranslate("ROLE"), "IFNULL((SELECT name FROM {'dbprefix'}roles WHERE id = {'dbprefix'}user.role),'')");
     $email = new TableColumn("email", Language::DirectTranslate("EMAIL"));
     $created = new TableColumn("create_timestamp", Language::DirectTranslate("CREATED_ON"));
     $created->autoWidth = true;
     $access = new TableColumn("last_access_timestamp", Language::DirectTranslate("LAST_ACCESS"));
     $access->autoWidth = true;
     $table->columns->add($id);
     $table->columns->add($name);
     $table->columns->add($role);
     $table->columns->add($email);
     $table->columns->add($created);
     $table->columns->add($access);
     $table->name = "{'dbprefix'}user";
     $table->actions = "userlist";
     $table->orderBy = "name";
     $table->cacheName = "userlist";
     $userlist->assign_var("TABLE", $table->getCode());
     $roles = new RoleSelector();
     $roles->hideSpecialRoles = true;
     $roles->name = "new_user_role";
     $userlist->assign_var("ROLES", $roles->getCode());
     $userlist->output();
 }
Example #22
0
 function authenticate_user($user_name, $user_pass)
 {
     // First determine if this is a local or ldap user
     if ($this->is_local_user($user_name, 'local')) {
         return $this->authenticate_local_user($user_name, $user_pass);
     } else {
         if (!($user_info = $this->authenticate_ldap_user($user_name, $user_pass))) {
             // Auth failed
             return false;
         }
         // Userinfo is an array which hold email and full name
         // Ok user is success fully authenticated
         // create user object and update / insert
         if (!($userid = $this->is_local_user($user_name, 'ldap'))) {
             $ldap_user = new User();
             $ldap_user->set_full_name($user_info["fullname"]);
             $ldap_user->set_email($user_info["email"]);
             $ldap_user->set_user_name($user_name);
             $ldap_user->set_user_type('ldap');
             // New user insert in local user
             if (!($userid = $ldap_user->insert())) {
                 // Unable to update local user cache
                 $this->error = $ldap_user->get_error();
                 return false;
             }
             // existing  user update in local user cache
         } else {
             $ldap_user = new User($userid);
             $ldap_user->set_full_name($user_info["fullname"]);
             $ldap_user->set_email($user_info["email"]);
             $ldap_user->set_user_name($user_name);
             $ldap_user->set_user_type('ldap');
             if (!$ldap_user->update()) {
                 // Unable to update local user cache
                 $this->error = $ldap_user->get_error();
                 return false;
             }
         }
         // get groups
         if (!($ldap_groups = $this->get_ldap_groups($user_name, $user_pass))) {
             return false;
         }
         if (!$this->update_ldap_groups($userid, $ldap_groups)) {
             // Unable to update local group cache
             return false;
         }
         return true;
     }
 }
Example #23
0
function editoccupant_POST(Web $w)
{
    list($householdid, $occupantid) = $w->pathMatch("a", "b");
    if (empty($householdid)) {
        $w->out("no household id provide");
        return;
    }
    $household = $w->Bend->getHouseholdForId($householdid);
    $oc = new BendHouseholdOccupant($w);
    $user = new User($w);
    $contact = new Contact($w);
    if (!empty($occupantid)) {
        $oc = $w->Bend->getHouseholdOccupantForId($occupantid);
    }
    $oc->fill($_POST);
    $oc->bend_household_id = $householdid;
    $oc->insertOrUpdate();
    if (!empty($oc->user_id)) {
        $user = $oc->getUser();
        $contact = $user->getContact();
    }
    $contact->fill($_POST);
    $contact->insertOrUpdate();
    // create a new user if necessary
    if (empty($user->id)) {
        $user->contact_id = $contact->id;
        $user->login = $contact->email;
        $user->is_active = 1;
        $user->redirect_url = "bend";
        $user->insert();
        // assign to bend users group
        $group = $w->Auth->getUserForLogin("Bend Users");
        if (empty($group)) {
            // create the group!
            $group = new User($w);
            $group->is_group = 1;
            $group->login = "******";
            $group->insert();
        }
        $gu = new GroupUser($w);
        $gu->group_id = $group->id;
        $gu->user_id = $user->id;
        $gu->role = "member";
        $gu->insert();
        $oc->user_id = $user->id;
        $oc->update();
    }
    $w->msg("Occupant updated", "/bend-household/show/{$household->bend_lot_id}/{$householdid}");
}
Example #24
0
function editlotowner_POST(Web $w)
{
    list($lotId, $lotOwnerId) = $w->pathMatch("lotId", "lotOwnerId");
    if (empty($lotId)) {
        $w->out("no lot id provide");
        return;
    }
    $lot = $w->Bend->getLotForId($lotId);
    $lotOwner = new BendLotOwner($w);
    $user = new User($w);
    $contact = new Contact($w);
    if (!empty($lotOwnerId)) {
        $lotOwner = $w->Bend->getBendLotOwnerForId($lotOwnerId);
    }
    $lotOwner->fill($_POST);
    $lotOwner->bend_lot_id = $lotId;
    $lotOwner->insertOrUpdate();
    if ($lotOwner->user_id) {
        $user = $lotOwner->getUser();
        $contact = $user->getContact();
    }
    $contact->fill($_POST);
    $contact->insertOrUpdate();
    // create a new user if necessary
    if (empty($user->id)) {
        $user->contact_id = $contact->id;
        $user->login = $contact->email;
        $user->is_active = 1;
        $user->redirect_url = "bend";
        $user->insert();
        // assign to bend users group
        $group = $w->Auth->getUserForLogin("Bend Users");
        if (empty($group)) {
            // create the group!
            $group = new User($w);
            $group->is_group = 1;
            $group->login = "******";
            $group->insert();
        }
        $gu = new GroupUser($w);
        $gu->group_id = $group->id;
        $gu->user_id = $user->id;
        $gu->role = "member";
        $gu->insert();
        $lotOwner->user_id = $user->id;
        $lotOwner->update();
    }
    $w->msg("Lot Owner updated", "/bend-lot/showlot/{$lotId}");
}
Example #25
0
 public function save()
 {
     $user = new User($_REQUEST['id']);
     if ($user->id) {
         $res = $user->update($_REQUEST);
         if ($res) {
             Registry::addMessage("Usuario actualizado satisfactoriamente", "success", "", Url::site("users"));
         }
     } else {
         $res = $user->insert($_REQUEST);
         if ($res) {
             Registry::addMessage("Usuario creado satisfactoriamente", "success", "", Url::site("users"));
         }
     }
     $this->ajax();
 }
Example #26
0
 public function signup()
 {
     if (isset($_POST['username'])) {
         Load::model('user');
         $User = new User();
         $info = $_POST;
         $User->insert($info);
         Load::redirect('admin/dashboard');
         // if successfull
         exit;
     } else {
         $param = array();
         $param['afid'] = isset($_GET['afid']) ? $_GET['afid'] : DEFAULT_AFID;
         Load::view('signup', $param);
         Load::hook_footer('signup');
     }
 }
 public static function register()
 {
     $email = Core::validate(self::getVar('email'));
     $pass = Core::validate(self::getVar('password'));
     $captcha = Core::validate(self::getVar('captcha'));
     if ($email == null || $pass == null || $captcha == null) {
         Core::printErrorJson('Incorrect data input');
         return;
     }
     $right_code = Session::getSessionVariable('security_code');
     Session::unsetSessionVariable('security_code');
     if ($captcha != $right_code) {
         Core::printErrorJson('Incorrect captcha');
         return;
     }
     if (!Core::isEmailAddress($email)) {
         Core::printErrorJson('Incorrect email');
         return;
     }
     if (User::isExist($email, $email)) {
         Core::printErrorJson('User ' . $email . ' is already registered.');
         return;
     }
     $usr = new User();
     $usr->setLogin($email);
     $usr->setEmail($email);
     $usr->setDate(date("Y-m-d H:i:s"));
     $usr->setActivation(0);
     $usr->setPassHash(Core::calculateHash($pass));
     $usr->insert();
     $activationCode = self::calcActivationCode($usr);
     $activationUrl = "http://" . $_SERVER['SERVER_NAME'] . "/usr/activation?login="******"&code=" . $activationCode;
     $subject = Core::translateToCurrentLocale("Registration confirmation") . ".";
     $header = '<h1>' . Core::translateToCurrentLocale("Hello") . ', </h1>
     <p class="lead">' . Core::translateToCurrentLocale("you have registered on the Bitmonex website") . '.</p>' . '<p>' . Core::translateToCurrentLocale("Your login is") . ': ' . $email . '</p><p>' . Core::translateToCurrentLocale("Your password is") . ': ' . $pass . '</p>';
     $body = '<p>' . Core::translateToCurrentLocale("To confirm your registration, please click on this link") . '. <a href="' . $activationUrl . '">' . Core::translateToCurrentLocale("Activate") . '!</a></p>';
     $message = self::getMessage($header, $body);
     if (!Core::send_mail($email, $subject, $message)) {
         $usr->delete();
         Core::printErrorJson('Notification email is not send.');
         return;
     }
     $result['success'] = 1;
     print json_encode($result);
 }
 /**
  * Create new User
  */
 public function create()
 {
     if ($this->slim->request->isGet()) {
         $this->slim->render('user/create.html.twig', ['sessionUser' => $this->getSessionUser()]);
     } elseif ($this->slim->request->isPost()) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $role = $_POST['role'];
         $auth = new Auth();
         $hash = $auth->hashPassword($password);
         $newUser = new User($this->slim->db);
         $newUser->setEmail($email);
         $newUser->setPassword($hash);
         $newUser->setRole($role);
         $newUser->insert();
         $this->slim->flash('success', 'User created');
         $this->slim->redirect('/users');
     }
 }
 public function googledoneAction()
 {
     $consumer = $this->getGoogleConsumer();
     $return_to = 'http://' . $_SERVER['HTTP_HOST'] . '/login/googledone';
     $response = $consumer->complete($return_to);
     if ($response->status == Auth_OpenID_CANCEL) {
         return $this->alert('取消登入', '/');
     }
     if ($response->status == Auth_OpenID_FAILURE) {
         return $this->alert('登入失敗: ' . $response->message, '/');
     }
     $ax = new Auth_OpenID_AX_FetchResponse();
     $obj = $ax->fromSuccessResponse($response);
     $email = $obj->data['http://axschema.org/contact/email'][0];
     if (!($user = User::search(array('user_name' => 'google://' . $email))->first())) {
         $user = User::insert(array('user_name' => 'google://' . $email));
     }
     Pix_Session::set('user_id', $user->user_id);
     return $this->redirect('/');
 }
Example #30
0
 /**
  * This setUp function changes the date string to a DateTime object, creates a segment, creates test values for user salt and hash, and then creates user and trail entries to use for testing
  */
 public function setUp()
 {
     parent::setUp();
     // necessary DateTime format to run the test
     $this->VALID_CREATEDATE = DateTime::createFromFormat("Y-m-d H:i:s", $this->VALID_CREATEDATE);
     //create points needed for segment
     $segmentStart = new Point(35.554, 44.546);
     $segmentStop = new Point(35.554, 48.445);
     //create new segment to use for testing
     $this->segment = new Segment(null, $segmentStart, $segmentStop, 7565, 9800);
     $this->segment->insert($this->getPDO());
     //create needed dependencies to ensure user can be created to run unit testing
     $this->salt = bin2hex(openssl_random_pseudo_bytes(32));
     $this->hash = hash_pbkdf2("sha512", "iLoveIllinois", $this->salt, 262144, 128);
     //create a new user to use for testing
     $this->user = new User(null, $this->VALID_BROWSER, $this->VALID_CREATEDATE, $this->VALID_IPADDRESS, "S", "*****@*****.**", $this->hash, "george kephart", $this->salt);
     $this->user->insert($this->getPDO());
     // create a trail to own test
     // Trail(trailId, userId, browser, createDate, ipAddress, submitTrailId, trailAccessibility, trailAmenities, trailConditions,
     $this->trail = new Trail(null, $this->user->getUserId(), "Safari", $this->VALID_CREATEDATE, $this->VALID_IPADDRESS, null, "y", "Picnic area", "Good", "This trail is a beautiful winding trail located in the Sandia Mountains", 3, 1054.53, "la luz trail", 1, "Mostly switchbacks with a few sections of rock fall", "Heavy", "Hiking", "fpfyRTmt6XeE9ehEKZ5LwF");
     $this->trail->insert($this->getPDO());
 }