function getUserForID($userId) { $user = new User(); ini_set('display_errors', 'On'); $db = "w4111c.cs.columbia.edu:1521/adb"; $conn = oci_connect("kpg2108", "test123", $db); $stmt = oci_parse($conn, "select * from users where user_Id='" . $userId . "'"); $rows = oci_execute($stmt); oci_close($conn); while ($row = oci_fetch_assoc($stmt)) { echo $row['LOGIN_ID']; $user->setUserId($row['USER_ID']); $user->setPassword($row['PASSWORD']); $user->setFirstName($row['FNAME']); $user->setLastName($row['LNAME']); $user->setLoginId($row['LOGIN_ID']); $user->setEmailId($row['EMAIL_ID']); $user->setAddress($row['ADDRESS']); $user->setPhoneNumber($row['PHONE_NO']); $user->setSecurityAnswer($row['ANSWER']); $user->setSecurityQuestion($row['QUESTION']); $user->setMiles($row['MILES']); } return $user; }
private static function getUserFromJSON($json) { $user = new User(); $user->setID($json['id']); $user->setName($json['name']); $user->setPhoneNumber($json['phoneNumber']); return $user; }
/** * Action to show the registration form */ public function executeIndex() { $this->wherefind = $this->getRequest()->getCookie('wherefind'); //If the user is logged in, don't let them regtutor if ($this->getUser()->isAuthenticated()) { $this->error = 'You are already logged in. You can not register again.'; return sfView::ERROR; } $this->requestedUserType = $this->getRequestedUserType(); //If the form hasn't yet been filled in, just display the form if (sfWebRequest::POST !== $this->getRequest()->getMethod()) { return sfView::SUCCESS; } if ($this->getRequestParameter('terms') != 1) { $this->error = 'You must agree to our <strong>Terms & Conditions</strong>. <a href="#" onClick="javascript: history.go(-1)">Click here</a> to go back to the previous page.'; return sfView::ERROR; } //Create and populate the User object $user = new User(); $user->setEmail($this->getRequestParameter('email')); $user->setPassword($this->getRequestParameter('password1')); $user->setName($this->getRequestParameter('realname')); // GENERATE USERNAME FROM FULL NAME FIELD $userName = str_replace(' ', '', strtolower($this->getRequestParameter('realname'))); $U_QRY = "select * from user where username='******'"; $u_res = mysql_query($U_QRY); $unamecount = mysql_num_rows($u_res); $dupval = 2; duplicationCheck: if ($unamecount >= 1) { $newUsername = $userName . $dupval; $unamequery = mysql_query("select * from user where username='******'"); $unamecount = mysql_num_rows($unamequery); if ($unamecount >= 1) { $dupval++; goto duplicationCheck; } else { $userName = $newUsername; } } $user->setUsername($userName); $user->setTypeUnconfirmed($this->requestedUserType); if (!$user->save()) { throw new PropelException('User creation failed'); } $uptSQL = "UPDATE user SET where_find_us='" . $this->getRequestParameter('where_find_us') . "' WHERE id='" . $user->getId() . "'"; mysql_query($uptSQL); if ($this->requestedUserType == UserPeer::getTypeFromValue('expert')) { $this->notify = $this->getRequestParameter('notify_email') . ',' . $this->getRequestParameter('notify_sms'); $user->setNotification($this->notify); $user->setPhoneNumber($this->getRequestParameter('phone_number')); $this->subscribeExpertToCategories($this->getRequestParameter('categories'), $user); } mysql_query("insert into expert_category(user_id,category_id) values('" . $user->getId() . "','1')") or die(mysql_error()); mysql_query("insert into user_score(user_id,score) values('" . $user->getId() . "','1')") or die(mysql_error()); $this->sendConfirmationEmail($user); $this->forward('regtutor', 'confirmationCodeSent'); }
static function put($id) { $json_user = json_decode($_POST['data'], true); $user = new User(); $user->setID($id); $user->setName($json_user['name']); $user->setPhoneNumber($json_user['phoneNumber']); UserStorage::updateUser($user); }
public function getAbonentByID($user_id) { try { $sql = "select * from users t1, phonenumbers t2 where t1.user_id=t2.user_id and t1.user_id=?"; $query = $this->db->query($sql, array($user_id)); $UserObj = new User(); if ($query->num_rows() > 0) { $row = $query->row_array(); $UserObj->setID($row['user_id']); $UserObj->setFirstName($row['first_name']); $UserObj->setLastName($row['last_name']); $UserObj->setAddress($row['address']); $UserObj->setPhoneNumber($row['phonenumber']); } return $UserObj; } catch (Exception $e) { throw new Exception($e->getMessage()); } }
public function import($adminUserId) { $count = 0; $add_method = $this->getValue('add_method'); $file = $this->getValue('file'); $delimiter = $this->getValue('delimiter'); $skipHeader = $this->getValue('skipHeader'); $fp = fopen($file->getTempName(), 'r'); if ($fp) { if ($add_method == self::REPLACE) { $c = new Criteria(); $c->add(UserPeer::ID, $adminUserId, Criteria::NOT_EQUAL); UserPeer::doDelete($c); } while ($data = fgetcsv($fp, 0, $delimiter)) { if (empty($data[0]) || count($data) < 7) { continue; } if ($skipHeader) { $skipHeader = false; continue; } try { $user = new User(); $user->setFamilyName($data[0]); $user->setSurname($data[1]); $user->setBirthdate($data[2]); $user->setCardNumber($data[3]); $user->setEmailAddress($data[4]); $user->setAddress($data[5]); $user->setPhoneNumber($data[6]); $user->autoCorrectNames(); $user->autoSetLogin(); $user->save(); ++$count; } catch (Exception $ex) { } } fclose($fp); return $count; } return false; }
$validator->addValidation("phoneNo", "numeric", "Please fill only numeric values for phone number"); $validator->addValidation("passwordRecoveryQues", "req", "Please fill in password recovery question"); $validator->addValidation("passwordRecoveryAns", "req", "Please fill in password recovery answer"); $validator->addValidation("email", "email", "The input for email should be a valid email value"); $validator->addValidation("email", "req", "Please fill in email"); if ($validator->ValidateForm()) { $_SESSION['action'] = "updateUser"; $user = new User(); $user->setUserId($_SESSION['userId']); $user->setLoginId($user1->getLoginId()); $user->setPassword($_REQUEST["password"]); $user->setFirstName($_REQUEST["firstName"]); $user->setLastName($_REQUEST["lastName"]); $user->setEmailId($_REQUEST["email"]); $user->setAddress($_REQUEST["address"]); $user->setPhoneNumber($_REQUEST["phoneNo"]); $user->setSecurityAnswer($_REQUEST["passwordRecoveryQues"]); $user->setSecurityQuestion($_REQUEST["passwordRecoveryAns"]); $_SESSION['userToBeUpdated'] = serialize($user); header("Location: ../controller/Controller.php"); } else { echo "<B>Validation Errors:</B>"; $error_hash = $validator->GetErrors(); foreach ($error_hash as $inpname => $inp_err) { echo "<p>{$inpname} : {$inp_err}</p>\n"; } } } $disp_loginName = isset($_POST['loginName']) ? $_POST['loginName'] : $user1->getLoginId(); $disp_password = isset($_POST['password']) ? $_POST['password'] : $user1->getPassword(); $disp_firstName = isset($_POST['firstName']) ? $_POST['firstName'] : $user1->getFirstName();
case 'GET': //echo 'GET req'; echo "Welcome to the Wringer API endpoints"; break; case 'POST': //echo 'creating a new user'; todo php:// works? //break; $user_post = json_decode(file_get_contents('php://input')); #print_r($_POST); #exit(); $no_errors = User::validate($user_post); if ($no_errors) { $user = new User(); $user->setFirstName($user_post->first_name); $user->setLastName($user_post->last_name); $user->setPhoneNumber($user_post->tel); if (User::inRelationship($user_post)) { // $user->setIsSingle(false); $user->setSpouseTel($user_post->tel2); } else { //$user->setIsSingle(true); $user->setSpouseTel(''); } //print_r($user);exit();//success require_once 'db_connect.php'; $response = array(); $user_created = $user->create(); if ($user_created) { $response['message'] = 'Signup sucessfull'; $response['success'] = 1; $response['data'] = User::getFullUserInfo($user->getPhoneNumber());
/** * Action to show the registration form */ public function executeIndex() { //If the user is logged in, don't let them register if ($this->getUser()->isAuthenticated()) { $this->error = 'You are already logged in. You can not register again.'; return sfView::ERROR; } $this->requestedUserType = $this->getRequestedUserType(); //If the form hasn't yet been filled in, just display the form if (sfWebRequest::POST !== $this->getRequest()->getMethod()) { return sfView::SUCCESS; } if ($this->getRequestParameter('terms') != 1) { $this->error = 'You must agree to our <strong>Terms & Conditions</strong>. <a href="#" onClick="javascript: history.go(-1)">Click here</a> to go back to the previous page.'; return sfView::ERROR; } //Create and populate the User object $user = new User(); $user->setEmail($this->getRequestParameter('email')); $user->setPassword($this->getRequestParameter('password1')); $user->setName($this->getRequestParameter('realname')); $expiration = substr($this->getRequestParameter('expiry_date'), 0, 2) . '/' . substr($this->getRequestParameter('expiry_date'), -2); require_once $_SERVER['DOCUMENT_ROOT'] . '/braintree_environment.php'; $result = Braintree_Customer::create(array('firstName' => $this->getRequestParameter('realname'), 'lastName' => '', 'creditCard' => array('cardholderName' => $this->getRequestParameter('realname'), 'number' => $this->getRequestParameter('credit_card'), 'cvv' => $this->getRequestParameter('cvv'), 'expirationDate' => $expiration, 'options' => array('verifyCard' => true)))); //error_log($result->customer->creditCards[0]->token, 0); if (false && !$result->success) { //error_log("invalid", 0); $this->error = 'Your credit card is invalid.'; return sfView::ERROR; } else { //should only save last 4 digit // $user->setCreditCard(substr($this->getRequestParameter('credit_card'),-4)); // $user->setCreditCardToken($result->customer->creditCards[0]->token); $userName = str_replace(' ', '', strtolower($this->getRequestParameter('realname'))); $U_QRY = "select * from user where username='******'"; $u_res = mysql_query($U_QRY); $unamecount = mysql_num_rows($u_res); $dupval = 2; duplicationCheck: if ($unamecount >= 1) { $newUsername = $userName . $dupval; $unamequery = mysql_query("select * from user where username='******'"); $unamecount = mysql_num_rows($unamequery); if ($unamecount >= 1) { $dupval++; goto duplicationCheck; } else { $userName = $newUsername; } } $user->setUsername($userName); $user->setTypeUnconfirmed($this->requestedUserType); if (!empty($_POST['coupon'])) { $query = mysql_query("select * from referral_code where referral_code='" . $_POST['coupon'] . "'") or die(mysql_error()); if (mysql_num_rows($query) > 0) { $rowValues = mysql_fetch_assoc($query); //$rowValues['user_id']; $query = mysql_query("select * from user where id=" . $rowValues['user_id']) or die(mysql_error()); $rowDetails = mysql_fetch_assoc($query); $newPoints = $rowDetails['points'] + 0.5; mysql_query("update user set points='" . $newPoints . "' where id=" . $rowValues['user_id']) or die(mysql_error()); mysql_query("delete from referral_code where referral_code='" . $_POST['coupon'] . "'") or die(mysql_error()); } else { if ($_POST['coupon'] == 'launch11') { $points = "10"; } elseif ($_POST['coupon'] == 'promo92') { $points = "12"; } elseif ($_POST['coupon'] == 'uoft9211') { $points = "8"; } } } if (!$user->save()) { throw new PropelException('User creation failed'); } if ($this->requestedUserType == UserPeer::getTypeFromValue('expert')) { $this->notify = $this->getRequestParameter('notify_email') . ',' . $this->getRequestParameter('notify_sms'); $user->setNotification($this->notify); $user->setPhoneNumber($this->getRequestParameter('phone_number')); $this->subscribeExpertToCategories($this->getRequestParameter('categories'), $user); } if (!empty($_POST['coupon']) && !empty($points)) { mysql_query("update user set points='" . $points . "' where id=" . $user->getId()) or die(mysql_error()); } elseif (!empty($_POST['coupon'])) { mysql_query("update user set points='11' where id=" . $user->getId()) or die(mysql_error()); } // Referral module // Rajesh Soni - 23 November 2012 if ($_POST['ref']) { $ref_by_user = mysql_real_escape_string($_POST['ref']); mysql_query("update user set referred_by='{$ref_by_user}' where id=" . $user->getId()) or die(mysql_error()); } mysql_query("insert into expert_category(user_id,category_id) values('" . $user->getId() . "','1')") or die(mysql_error()); mysql_query("insert into user_score(user_id,score) values('" . $user->getId() . "','1')") or die(mysql_error()); $this->sendConfirmationEmail($user); $this->forward('register', 'confirmationCodeSent'); } }