public static function getPrivateContestsCount(Users $user) { $sql = 'SELECT count(*) as Total FROM Contests WHERE public = 0 and (director_id = ?);'; $params = array($user->getUserId()); global $conn; $rs = $conn->GetRow($sql, $params); if (!array_key_exists('Total', $rs)) { return 0; } return $rs['Total']; }
/** * Given an User, checks that login let state as supposed * * @param Users $user * @param type $auth_token */ public function assertLogin(Users $user, $auth_token = null) { // Check auth token $authTokenKey = new AuthTokens(array("user_id" => $user->getUserId())); $auth_tokens_bd = AuthTokensDAO::search($authTokenKey); // Validar que el token se guardó en la BDD if (!is_null($auth_token)) { $exists = false; foreach ($auth_tokens_bd as $token_db) { if (strcmp($token_db->getToken(), $auth_token) === 0) { $exists = true; break; } } if ($exists === false) { $this->fail("Token {$auth_token} not in DB."); } } // @todo check last access time }
$religion = $_REQUEST['religion_id'] ? $_REQUEST['religion_id'] : 'Any'; $dating_pref = $_REQUEST['dating_pref_id'] ? $_REQUEST['dating_pref_id'] : 'Any'; $sexual_pref = $_REQUEST['sexual_pref_id'] ? $_REQUEST['sexual_pref_id'] : 'Any'; $height = $_REQUEST['height'] ? $_REQUEST['height'] : 'Any'; $profile_pic = $_FILES['profile_pic']; $bio = $_REQUEST['bio'] ? $_REQUEST['bio'] : ''; $gender = $_REQUEST['gender'] ? $_REQUEST['gender'] : ''; $age = $_REQUEST['age'] ? $_REQUEST['age'] : ''; $city = $_REQUEST['city'] ? $_REQUEST['city'] : ''; $employment_place = $_REQUEST['employment_place'] ? $_REQUEST['employment_place'] : ''; if (!$token) { $success = "0"; $msg = "Incomplete Parameters"; $data = array(); } else { $uid = Users::getUserId($token); $fbid = Users::getUserfbId($token); if ($uid) { if ($profile_pic) { $randomFileName = randomFileNameGenerator("Img_") . "." . end(explode(".", $profile_pic['name'])); if (@move_uploaded_file($profile_pic['tmp_name'], "../uploads/{$randomFileName}")) { $profile_pic_path = $randomFileName; } } else { $profile_pic_path = ""; } $education_id = Options::getEducationOptionId($education); $profession_id = Options::getProfessionOptionId($profession); $relation_id = Options::getRelationOptionId($relation); $food_pref_id = Options::getFoodPrefId($food_pref); $drinking_id = Options::getDrinkingOptionId($drinking);
// +-----------------------------------+ // + STEP 2: get data + // +-----------------------------------+ $token = $_REQUEST['token']; $gallery_id = $_REQUEST['image_id']; $flag = $_REQUEST['flag'] ? $_REQUEST['flag'] : '1'; if (!($token && $gallery_id)) { $success = "0"; $msg = "Incomplete Parameters"; $data = array(); } else { // +-----------------------------------+ // + STEP 3: perform operations + // +-----------------------------------+ //fetching user_id and name based on token $user_id = Users::getUserId($token); if ($user_id) { $sql = "select * from picture_like where user_id=:user_id and gallery_id=:gallery_id"; $sth = $conn->prepare($sql); $sth->bindValue('user_id', $user_id); $sth->bindValue('gallery_id', $gallery_id); try { $sth->execute(); } catch (Exception $e) { } $likes = $sth->fetchAll(); if (count($likes)) { $sql = "UPDATE picture_like set status=:status where user_id=:user_id and gallery_id=:gallery_id"; $sth = $conn->prepare($sql); $sth->bindValue('user_id', $user_id); $sth->bindValue('gallery_id', $gallery_id);
public function loginDoneGoogle() { $code = Input::get('code'); $googleService = OAuth::consumer('Google', 'http://www.obscuraconflu.com/google'); $token = $googleService->requestAccessToken($code); // Send a request with it $result = json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo'), true); //Var_dump //display whole array(). $userId = Users::getUserId($result['id']); if ($userId) { Auth::loginUsingId($userId); $firstname = Users::getFirstName($userId); Session::put('first_name', $firstname); $data = "Welcome "; return Redirect::to('/dashboard')->with('message', $data . " " . $firstname); } else { $newUserData['first_name'] = $result['given_name']; $newUserData['last_name'] = $result['family_name']; $newUserData['email'] = $result['email']; $newUserData['uid'] = $result['id']; $newUserData['signup_type'] = 3; //$newUserData['profile_image'] = "https://graph.facebook.com/"+$result['id']+"/picture?width=250&height=250"; Session::put('fb', $newUserData); return View::make('fbgoogle')->with('newUserData', $newUserData); } }
<?php session_start(); require_once '../core/User.class.php'; if (isset($_POST['sign-in'])) { $user = new Users($_POST['user'], md5($_POST['password'])); //echo $user->getUserNick().'<br/>'; //echo $user->getUserPassword().'<br/>'; //$user->checkUser(); //echo $user->getUserId(); if ($user->checkUser()) { $_SESSION['admin']['admin_id'] = $user->getUserId(); $_SESSION['admin']['admin_nick'] = $user->getUserNick(); //echo "checkUser"; header("Location: ../../../"); } else { //echo "No checkUser"; header("Location: ../../../"); } } else { //echo "prueba"; header("Location: ../../../"); }
private function RegisterSession(Users $vo_User, $b_ReturnAuthTokenAsString = false) { // Log the login. UserLoginLogDAO::save(new UserLoginLog(array('user_id' => $vo_User->user_id, 'ip' => ip2long($_SERVER['REMOTE_ADDR'])))); // Expire the local session cache. self::$current_session = null; //find if this user has older sessions $vo_AuthT = new AuthTokens(); $vo_AuthT->setUserId($vo_User->getUserId()); //erase expired tokens try { $tokens_erased = AuthTokensDAO::expireAuthTokens($vo_User->getUserId()); } catch (Exception $e) { // Best effort self::$log->error("Failed to delete expired tokens: {$e->getMessage}()"); } // Create the new token $entropy = bin2hex(mcrypt_create_iv(SessionController::AUTH_TOKEN_ENTROPY_SIZE, MCRYPT_DEV_URANDOM)); $s_AuthT = $entropy . '-' . $vo_User->getUserId() . '-' . hash('sha256', OMEGAUP_MD5_SALT . $vo_User->getUserId() . $entropy); $vo_AuthT = new AuthTokens(); $vo_AuthT->setUserId($vo_User->getUserId()); $vo_AuthT->setToken($s_AuthT); try { AuthTokensDAO::save($vo_AuthT); } catch (Exception $e) { throw new InvalidDatabaseOperationException($e); } if (self::$setCookieOnRegisterSession) { $sm = $this->getSessionManagerInstance(); $sm->setCookie(OMEGAUP_AUTH_TOKEN_COOKIE_NAME, $s_AuthT, 0, '/'); } Cache::deleteFromCache(Cache::SESSION_PREFIX, $s_AuthT); if ($b_ReturnAuthTokenAsString) { return $s_AuthT; } }
/** * Declares an association between this object and a Users object. * * @param Users $v * @return UserRides The current object (for fluent API support) * @throws PropelException */ public function setUsers(Users $v = null) { if ($v === null) { $this->setUserId(NULL); } else { $this->setUserId($v->getUserId()); } $this->aUsers = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Users object, it will not be re-added. if ($v !== null) { $v->addUserRides($this); } return $this; }
/** * Declares an association between this object and a Users object. * * @param Users $v * @return UserInformation The current object (for fluent API support) * @throws PropelException */ public function setUsers(Users $v = null) { if ($v === null) { $this->setUserId(0); } else { $this->setUserId($v->getUserId()); } $this->aUsers = $v; // Add binding for other direction of this 1:1 relationship. if ($v !== null) { $v->setUserInformation($this); } return $this; }
public static function getPrivateCount(Users $user) { $sql = "SELECT count(*) as Total FROM Problems WHERE public = 0 and (author_id = ?);"; $params = array($user->getUserId()); global $conn; $rs = $conn->GetRow($sql, $params); if (!array_key_exists("Total", $rs)) { return 0; } return $rs["Total"]; }
}; // Authentication $app['auth'] = function () use($app, $config) { $auth = array(); $authorization = $app->request->getHeader("AUTHORIZATION"); if ($authorization) { $cut = str_replace('Basic ', '', $authorization); $creds = explode(':', base64_decode($cut)); $auth['login'] = $creds[0]; $auth['password'] = $creds[1]; } else { $auth['login'] = null; $auth['password'] = null; } $usr = new Users(); $auth['id'] = $usr->getUserId($auth['login'], $auth['password']); return $auth; }; // CoreController if ($app['controllers']['core']) { $core = new MicroCollection(); // Set the handler & prefix $core->setHandler(new CoreController($app)); $core->setPrefix('/'); // Set routers $core->get('/', 'index'); $app->mount($core); } // MessagesController if ($app['controllers']['messages']) { $messages = new MicroCollection();
public function executeNewUser() { $this->hide = false; //check to see if exists $c = new Criteria(); $c->add(UsersPeer::USERNAME, $this->getRequestParameter('username')); $userExist = UsersPeer::doSelectOne($c); if ($userExist) { $this->errors = 'Username already exists, please select another username.'; } else { //check passwords $pass = $this->getRequestParameter('password'); $vpass = $this->getRequestParameter('vpassword'); if ($pass == $vpass) { $user = new Users(); $user->setFname($this->getRequestParameter('fname')); $user->setLname($this->getRequestParameter('lname')); $user->setEmail($this->getRequestParameter('email')); $user->setUsername($this->getRequestParameter('username')); $user->saltPassword($this->getRequestParameter('password')); //send email for account activation $confCode = sha1($user->getSalt() . $user->getUsername()); $user->save(); $this->sendMail($user->getUsername(), $confCode, $user->getUserId(), $user->getEmail()); $this->errors = ''; $this->hide = true; } else { $this->errors = 'Passwords do not match, please re-enter'; } } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Users $value A Users object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Users $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getUserId(); } // if key === null self::$instances[$key] = $obj; } }
<?php require_once '../phpInclude/dbconnection.php'; require_once '../classes/AllClasses.php'; $token = $_REQUEST['token']; $description = $_REQUEST['description']; $location = $_REQUEST['location']; $user = new Users(); $general = new GeneralFunctions(); if ($token) { $user_id = $user->getUserId($token); echo $user_id; die; $hangout_id = $general->createHangout($user_id, $description, $location); $details = $general->getHangoutDetails($hangout_id); $success = '1'; $msg = 'Hangout created'; } echo json_encode(array('success' => $success, 'msg' => $msg, 'details' => $details));