Ejemplo n.º 1
0
<?php

include "./core/bootstrap.php";
//make sure no fields are blank
if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2']) {
    die('You did not complete all required fields');
}
//check that both passwords match
if ($_POST['pass'] != $_POST['pass2']) {
    die('Your passwords did not match.');
}
//get the user's username
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['pass'];
$userService = new UserService();
$regUserResult = $userService->registerUser($username, $password, $email);
if (!$regUserResult["result"]) {
    die($regUserResult["error"]);
} else {
    $userid = $regUserResult["userid"];
    $passhash = $regUserResult["passhash"];
    // if login is ok then we add a cookie
    $hour = time() + 57600;
    //Here, we set 2 cookies--one containing the username, and the other
    //containing the hashed password, both of which expire in one hour
    setcookie(ID_my_site, $userid, $hour);
    setcookie(Key_my_site, $passhash, $hour);
    //then redirect them to the new members area
    header("Location: newmember.php");
}
Ejemplo n.º 2
0
<?php

//TODO: Replace with phpunit
include "../core/bootstrap.php";
$dbHelper = new DBHelper();
$propKeys = array("prop1", "prop2", "prop3");
echo $dbHelper::genPlaceholderList($propKeys) . "\n\n";
$userService = new UserService();
var_dump($userService->registerUser("tester8", "test", "*****@*****.**"));
$CDAO = new ClimbingAreaDAO();
$areaid = 7;
$indoor = 1;
var_dump($CDAO->climbingAreaExists($areaid, $indoor));
$UserDAO = new UserDAO();
echo $UserDAO->getNumUsers();
var_dump($UserDAO->getUserPrefs(954));
var_dump($UserDAO->setUserPrefs(954, array("show_boulder" => 1, "minL" => 3)));
var_dump($UserDAO->getUserPrefs(954));
var_dump($UserDAO->getUserProfile(954));
var_dump($UserDAO->getUserRecords(954));
$WorkoutService = new WorkoutLoggingService();
$workout_segments_abs = array(array("climb_type" => "boulder", "ascent_type" => "flash", "grade_index" => 1, "reps" => 1), array("climb_type" => "toprope", "ascent_type" => "project", "grade_index" => 9, "reps" => 5), array("climb_type" => "lead", "ascent_type" => "redpoint", "grade_index" => 11, "reps" => 6), array("climb_type" => "boulder", "ascent_type" => "onsight", "grade_index" => 13, "reps" => 2));
var_dump($WorkoutService->calcWorkoutPoints($workout_segments_abs));
// Save a workout
$DBManager = new DBConnectionManager();
$db = $DBManager->connect();
// userid, date_workout, gymid, boulder_notes,
// tr_notes, lead_notes, other_notes
$userid = 4;
$workout_info = array("userid" => $userid, "date_workout" => "2015-10-23", "gymid" => 1, "boulder_notes" => "bouldering!", "tr_notes" => "tr rocks", "lead_notes" => "", "other_notes" => "other notes!!!");
$workout_info["boulder_points"] = 200;