public function actionEdit_status() { $user = new User(); $user->find()->where(['id' => $_POST['userID']])->one(); $user->status = $_POST['status']; $user->save(); }
public function actionSave_profile() { if (isset($_POST['saveProfile'])) { $user = new User(); $usServ = new UserServices(); $vk_id = Cookie::get('vk_id'); $user->find()->where(['vk_id' => $vk_id])->one(); $usServ->deleteByField('user_id', $user->id); $user->region_id = $_POST['region_id']; $user->city_id = $_POST['city_id']; $user->email = $_POST['email']; $user->phone = $_POST['phone']; $user->link = $_POST['link']; $user->save(); foreach ($_POST['services'] as $serv) { $usServ = new UserServices(); $usServ->user_id = $user->id; $usServ->service_id = $serv; $usServ->save(); } header('Location: /vk2/office/my', true, 302); } else { Header::redirect('/vk2/profile/my', true, 302); } }
protected function create() { $params = arrayKeysSnakeToCamel($_POST['user']); $user = new User(); $user->fromArray($params); $user->save(); $this->addFlash("success", "registered"); redirectTo("/"); }
public static function register($email, $nick, $password) { $user = new User(); $user->email = $email; $user->nick = $nick; $user->password = password_hash($password, PASSWORD_DEFAULT); $user->save(); return $_SESSION['user'] = $user->id; }
public function actionCreate() { $user = new User(); $user->scenario = 'create'; if (isset($_POST['User']) && is_array($_POST['User']) && $user->load($_POST['User']) && $user->save()) { $this->redirect(['site/index']); } $this->render('create', ['user' => $user]); }
public function actionReg() { $vk_id = $this->app->cookie->get('vk_id'); $user = new User(); $user->find()->where(['vk_id' => $vk_id])->one(); $user->status = $_GET['status'] == 1 ? 2 : 1; $user->save(); $this->app->parser->render('profile', ['user' => $user]); }
public function actionMy() { $vk_id = Cookie::get('vk_id'); $user = new User(); $user->find()->where(['vk_id' => $vk_id])->one(); $user->status = $_GET['status'] == 1 ? 2 : 1; $user->save(); $region = new GeobaseRegion(); $city = new GeobaseCity(); $regionAll = $region->find()->orderBy('name', 'ASC')->all(); $this->app->parser->render('profile', ['user' => $user, 'regionAll' => $regionAll]); }
function registerUser($postdata) { $regname = htmlentities($postdata['regname']); $regpass = htmlentities($postdata['regpass']); $regauth = htmlentities($postdata['regauth']); $regpass = hash('sha256', $regpass); $user = new User(); $user->setName($regname); $user->setPassword($regpass); $user->setAuthlevel($regauth); $user->save(); }
public function actionReg() { $vk_id = Cookie::get('vk_id'); $user = new User(); $user->find()->where(['vk_id' => $vk_id])->one(); $user->status = $_GET['status'] == 1 ? 2 : 1; $user->save(); Header::redirect('/vk2/profile/my', true, 302); /*$this->app->parser->render('profile', [ 'user' =>$user, ]);*/ }
/** * Creates a New account * @param Request object - which contains email, password etc * * @return Nothing */ public function create_new_account(Application $app, Request $request) { $email = $request->get('email'); $password = $app->escape($request->get('password')); $confirm_password = $request->get('confirm_password'); $user = new User($app); try { $user->save('user', array('email' => $email, 'password' => md5($password), 'create_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s"))); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } return $app->render('tweets.php.twig', array('error_message' => '', 'tweets' => [])); }
public function registerAction() { $user = new User(); $success = $user->save($this->request->getPost()); if ($success) { return $this->redirect('signin/index'); } else { echo 'Sorry, the following problems were generated: '; foreach ($user->getMessages() as $message) { echo $message->getMessage(), '<br/>'; } } $this->view->disable(); }
public function postRegister(Request $request) { $validator = Validator::make($request->all(), ['login' => 'required|min:4|max:25|unique:user,login', 'pseudo' => 'required|min:4|max:25|unique:user,pseudo', 'password' => 'required|min:6|max:20|confirmed', 'email' => 'required|max:100|email|unique:user,email']); if ($validator->fails()) { return redirect()->back()->withErrors($validator->errors())->withInput(); } $u = new User(); $u->login = $request->input('login'); $u->pseudo = $request->input('pseudo'); $u->email = $request->input('email'); $u->password = Hash::make($request->input('password')); $u->streaming = 0; $u->save(); return redirect(route('getLogin')); }
public function registerAction() { if (F::$app->getRequest()->getIsPost()) { $item = new User(); $item->username = $_POST['username']; $item->password = $_POST['password']; $item->repassword = $_POST['repassword']; $item->date_created = time(); if ($item->save()) { return "User was registered"; } else { return "User was not registered"; } } return $this->render('register'); }
public function register() { if (isset($_POST['login'])) { $this->redirect('users', 'login'); exit; } if (isset($_POST['register'])) { $username = $_POST['username']; $email = $_POST['email']; $password = $_POST['password']; $confirm = $_POST['confirm']; if ($username == null) { echo 'Enter Valid Username!'; die; } if ($email == null) { echo 'Enter email!'; die; } if ($password == null) { echo 'Enter password!'; die; } if ($confirm == null) { echo 'Confirm password!'; die; } if ($_POST['password'] != $_POST['confirm']) { echo 'Confirm password and password are not the same!'; die; } $user = new User($username, $password, $email); $user->save(); $userInstance = UserRepository::create()->getByName($username); $newUserId = intval($userInstance['id']); var_dump($userInstance); if ($userInstance) { CartRepository::create()->newCart($newUserId); } $this->redirect('users', 'login'); } }
/** * Update the given user. * * @param Users $user * The user to update * @param array $data * an array that contains the following fields :<pre> * name * email * password * </pre> * @return boolean true if there is nothing to update or updating was done successfully, false otherwise. * */ public static function updateUser(User $user, $data = array()) { if (!$user instanceof User) { return false; } $needsUpdate = false; if (isset($data['name'])) { $user->display_name = $data['display_name']; $needsUpdate = true; } if (isset($data['password'])) { $user->password = Hash::make($data['password']); $needsUpdate = true; } if ($needsUpdate) { return $user->save(); } else { return true; } }
public function registerAction() { $user = new User(); $data = $this->request->getPost(); $user->password = isset($data['password']) ? $data['password'] : null; $user->retype_password = isset($data['retype_password']) ? $data['retype_password'] : null; if ($user->save($data)) { if ($this->getUser()->login($user->email, $user->password)) { return $this->redirect('account/index'); } else { return $this->redirect('signin/index'); } } else { echo 'Sorry, the following problems were generated: '; foreach ($user->getMessages() as $message) { echo $message->getMessage(), '<br/>'; } } $this->view->disable(); }
public static function register($username, $password, $email) { $error = ["user" => TRUE, "email" => TRUE]; try { User::where('username', $username)->firstOrFail(); echo "username already exists.<br>"; } catch (Exception $e1) { $error["user"] = FALSE; } try { User::where('email', $email)->firstOrFail(); echo "email already exists.<br>"; } catch (Exception $e2) { $error["email"] = FALSE; } if (!$error["user"] && !$error["email"]) { $now = Carbon::now('Asia/Dhaka'); $salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647)); $password = hash('sha256', $password . $salt); $user = new User(array('username' => $username, 'password' => $password, 'salt' => $salt, 'email' => $email, 'created_at' => $now, 'updated_at' => $now)); $user->save(); } return $error; }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aUser !== null) { if ($this->aUser->isModified() || $this->aUser->isNew()) { $affectedRows += $this->aUser->save($con); } $this->setUser($this->aUser); } if ($this->aGroup !== null) { if ($this->aGroup->isModified() || $this->aGroup->isNew()) { $affectedRows += $this->aGroup->save($con); } $this->setGroup($this->aGroup); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); $affectedRows += 1; } else { $affectedRows += $this->doUpdate($con); } $this->resetModified(); } $this->alreadyInSave = false; } return $affectedRows; }
/** * Store users login data - ip and visit time * * @param \Models\User $user * @return void */ private static function saveUserVisit(Models\User $user) { $user->lastVisit = Timer::now(); $user->lastIP = Request::clientIP(); $user->save(['lastVisit', 'lastIP', 'cookie']); }
protected function create() { if (isset($_POST["email"]) && isset($_POST["username"]) && isset($_POST["password"])) { $user = new User(); $emailConfirmToken = uniqid() . generateRandomString(19); $user->fromArray(array("Email" => $_POST["email"], "Username" => $_POST["username"], "Password" => $_POST["password"], "EmailConfirmToken" => $emailConfirmToken)); if (!$user->save()) { $failures = $user->getValidationFailures(); if (count($failures) > 0) { foreach ($failures as $failure) { $this->sendFlashMessage("You have not been signed up. " . $failure->getMessage(), "error"); } } } else { $this->sendFlashMessage('You have been successfuly signed up. Please confirm your email address, we have send confirmation link. <a class="link" href="/user/' . $user->getUsername() . '/send-email-confirm-email">Send new email confirm link?</a>', "success"); $body = '<p>You have created new account on Starling.</p><br /><p>Please virify your email address by clicking this url:</p><a href="' . $this->siteURL . '/user/' . $user->getUsername() . '/email-confirm/' . urlencode($emailConfirmToken) . '">' . $this->siteURL . '/user/' . $user->getUsername() . '/email-confirm/' . urlencode($emailConfirmToken) . '</a>'; $transport = \Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername($this->emailAddress)->setPassword($this->emailPassword); $mailer = \Swift_Mailer::newInstance($transport); $message = \Swift_Message::newInstance()->setSubject('Email verification')->setFrom(array($this->emailAddress => 'Starling admin'))->setTo(array($user->getEmail() => $user->getUsername()))->setBody($body, 'text/html'); $result = $mailer->send($message); } $this->redirect("/"); } else { setHTTPStatusCode("400"); } }
public function run() { DB::statement('SET FOREIGN_KEY_CHECKS=0;'); DB::table('user')->truncate(); DB::table('role')->truncate(); DB::table('role_user')->truncate(); DB::table('event')->truncate(); DB::table('exp_level')->truncate(); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); $faker = Factory::create(); $uQ = new User(); $uQ->login = '******'; $uQ->pseudo = 'QsAnakrose'; $uQ->password = Hash::make('quentin'); $uQ->email = '*****@*****.**'; $uQ->streaming = 1; $uQ->twitch_channel = 'riotgames'; $uQ->save(); $data = []; for ($i = 0; $i < 110; $i++) { $username = $faker->unique()->username; $data[] = ['login' => $username, 'pseudo' => $username, 'email' => $faker->unique()->freeEmail, 'password' => Hash::make($username)]; } User::insert($data); $this->command->info('Users created'); $admin = new Role(); $admin->title = 'admin'; $admin->save(); $streamer = new Role(); $streamer->title = 'streamer'; $streamer->save(); $this->command->info('Roles created'); $uQ->becomeAdmin(); $uQ->becomeStreamer(); for ($i = 2; $i < 13; $i++) { $u = User::find($i); $u->becomeStreamer(); $u->twitch_channel = $i; $u->description = $u->login . 'lorem ipsum dolor. Lol.'; $rand = rand(0, 2); if ($rand == 0) { $u->streaming = 1; } else { $u->streaming = 0; } /* $avatarManager = new AvatarManager(); $intervManager = $avatarManager->getImgManager(); $width = $avatarManager->getAvatarWidth(); $color = substr(md5(rand()), 0, 6); $intervManager->canvas($width, $width, $color); */ $u->save(); } $su = new StreamingUserService(); $su->update(); $this->command->info('Roles attached'); $event = new Event(); $event->title = 'Hugo'; $event->start = '2015-06-26T12:30:00+02:00'; $event->end = '2015-06-26T15:30:00+02:00'; $event->allDay = 'false'; $event->color = '#FF0000'; $event->timezone = '+02:00'; $event->save(); $this->command->info('Test event created'); $expManager = new ExperienceManager(); $data = $expManager->generateExperienceSystem(); ExpLevel::insert($data); $this->command->info('Experience system initialized'); }
public function detailspost() { $f3 = \Base::instance(); $this->_requireLogin(); $this->_requireRank('support'); $user = $f3->get('user'); $user_obj = $f3->get('user_obj'); $user_org_links = $f3->get('user_org_links'); $db = $f3->get('db.instance'); // Target user $tuser_id = $f3->get('PARAMS.id'); $tuser = new User(); $tuser->load($tuser_id); if ($tuser->rank > $user['rank']) { $f3->reroute($f3->get('PATH')); } // Update one by one $name = $f3->get('POST.tname'); $username = $f3->get('POST.tusername'); $email = $f3->get('POST.temail'); $age = (int) $f3->get('POST.tage'); $rank = $f3->get('POST.trank'); $errors = []; if (empty($name)) { $errors[] = "Name is required"; } if (!preg_match("/^[0-9a-z]{4,}\$/i", $username)) { $errors[] = "Usernames must be at least 4 characters and can only contain letters and numbers."; } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors[] = "A valid email address is required."; } // Prevent setting the users rank to a rank higher then the user's one if ($rank > $user['rank']) { $errors[] = 'You can not set the users rank to a rank higher then yours'; } if (empty($errors)) { $tuser->name = $name; $tuser->username = $username; $tuser->email = $email; $tuser->age = $age; $tuser->rank = $rank; $tuser->save(); new Notification('Updated users profile successfully !', 'success', true); $f3->reroute($f3->get('PATH')); } else { $f3->set('errors', $errors); $f3->set('tuser', $tuser->cast()); $f3->set('target', 'dashboard/admin/users/details.html'); $this->_render('base.html'); } }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aUser !== null) { if ($this->aUser->isModified() || $this->aUser->isNew()) { $affectedRows += $this->aUser->save($con); } $this->setUser($this->aUser); } if ($this->aCategory !== null) { if ($this->aCategory->isModified() || $this->aCategory->isNew()) { $affectedRows += $this->aCategory->save($con); } $this->setCategory($this->aCategory); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); $affectedRows += 1; } else { $affectedRows += $this->doUpdate($con); } $this->resetModified(); } if ($this->subNotesScheduledForDeletion !== null) { if (!$this->subNotesScheduledForDeletion->isEmpty()) { \Models\SubNoteQuery::create()->filterByPrimaryKeys($this->subNotesScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->subNotesScheduledForDeletion = null; } } if ($this->collSubNotes !== null) { foreach ($this->collSubNotes as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->filesScheduledForDeletion !== null) { if (!$this->filesScheduledForDeletion->isEmpty()) { \Models\FileQuery::create()->filterByPrimaryKeys($this->filesScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->filesScheduledForDeletion = null; } } if ($this->collFiles !== null) { foreach ($this->collFiles as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->notificationsScheduledForDeletion !== null) { if (!$this->notificationsScheduledForDeletion->isEmpty()) { foreach ($this->notificationsScheduledForDeletion as $notification) { // need to save related object because we set the relation to null $notification->save($con); } $this->notificationsScheduledForDeletion = null; } } if ($this->collNotifications !== null) { foreach ($this->collNotifications as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->commentsScheduledForDeletion !== null) { if (!$this->commentsScheduledForDeletion->isEmpty()) { \Models\CommentQuery::create()->filterByPrimaryKeys($this->commentsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->commentsScheduledForDeletion = null; } } if ($this->collComments !== null) { foreach ($this->collComments as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->sharedsScheduledForDeletion !== null) { if (!$this->sharedsScheduledForDeletion->isEmpty()) { foreach ($this->sharedsScheduledForDeletion as $shared) { // need to save related object because we set the relation to null $shared->save($con); } $this->sharedsScheduledForDeletion = null; } } if ($this->collShareds !== null) { foreach ($this->collShareds as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aUser !== null) { if ($this->aUser->isModified() || $this->aUser->isNew()) { $affectedRows += $this->aUser->save($con); } $this->setUser($this->aUser); } if ($this->aArticle !== null) { if ($this->aArticle->isModified() || $this->aArticle->isNew()) { $affectedRows += $this->aArticle->save($con); } $this->setArticle($this->aArticle); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); $affectedRows += 1; } else { $affectedRows += $this->doUpdate($con); } $this->resetModified(); } if ($this->ratingsScheduledForDeletion !== null) { if (!$this->ratingsScheduledForDeletion->isEmpty()) { \Models\RatingQuery::create()->filterByPrimaryKeys($this->ratingsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->ratingsScheduledForDeletion = null; } } if ($this->collRatings !== null) { foreach ($this->collRatings as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aOwner !== null) { if ($this->aOwner->isModified() || $this->aOwner->isNew()) { $affectedRows += $this->aOwner->save($con); } $this->setOwner($this->aOwner); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); $affectedRows += 1; } else { $affectedRows += $this->doUpdate($con); } $this->resetModified(); } if ($this->usersScheduledForDeletion !== null) { if (!$this->usersScheduledForDeletion->isEmpty()) { $pks = array(); foreach ($this->usersScheduledForDeletion as $entry) { $entryPk = []; $entryPk[1] = $this->getId(); $entryPk[0] = $entry->getId(); $pks[] = $entryPk; } \Models\UserGroupQuery::create()->filterByPrimaryKeys($pks)->delete($con); $this->usersScheduledForDeletion = null; } } if ($this->collUsers) { foreach ($this->collUsers as $user) { if (!$user->isDeleted() && ($user->isNew() || $user->isModified())) { $user->save($con); } } } if ($this->packPermissionsScheduledForDeletion !== null) { if (!$this->packPermissionsScheduledForDeletion->isEmpty()) { \Models\PackPermissionQuery::create()->filterByPrimaryKeys($this->packPermissionsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->packPermissionsScheduledForDeletion = null; } } if ($this->collPackPermissions !== null) { foreach ($this->collPackPermissions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->userGroupsScheduledForDeletion !== null) { if (!$this->userGroupsScheduledForDeletion->isEmpty()) { \Models\UserGroupQuery::create()->filterByPrimaryKeys($this->userGroupsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->userGroupsScheduledForDeletion = null; } } if ($this->collUserGroups !== null) { foreach ($this->collUserGroups as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
public function create() { if ($_POST['regPassword'] != $_POST['regPassword2']) { $this->addPopup('danger', 'Hesla se neshodují.'); redirectTo("/registrace"); } if (!User::checkRegistrationValidity()) { redirectTo("/registrace"); } $existing = User::checkExistingUsernameEmail(); if ($existing != NULL) { if ($existing->getUsername() == $_POST["regUsername"]) { $this->addPopup('danger', 'Uživatel se stejným uživatelským jménem je již zaregistrován.'); } elseif ($existing->getEmail() == $_POST["regEmail"]) { $this->addPopup('danger', 'Uživatel se stejnou emailovou adresou je již zaregistrován.'); } redirectTo("/registrace"); } else { $token = token(50); $user = new User(); $user->setIdImage(6); $user->setUsername(strip_tags($_POST['regUsername'])); $user->setPassword(strip_tags(sha1($_POST['regPassword']))); $user->setEmail(strip_tags($_POST['regEmail'])); $user->setUrl(strip_tags($_POST['regUsername'])); $user->setEmailConfirmToken($token); $user->setPasswordResetToken(NULL); $user->setPermissions(0); $user->setSigninCount(0); sendEmailConfirmationToken($user->getUsername(), $user->getEmailConfirmToken(), $user->getEmail()); $user->save(); $this->addPopup('success', 'Registrace proběhla úspěšně! Nyní se můžete přihlásit.'); redirectTo("/"); } }