<?php

include './core/bootstrap.php';
//connect to database
include 'dbconnect.php';
//check that user has a valid cookie, redirect if no valid cookie
include 'php_common/cookiecheck.php';
$workoutId = $_GET['wid'];
$workoutLoggingService = new WorkoutLoggingService();
$workoutInfo = $workoutLoggingService->getWorkoutInfo($workoutId);
$workoutUserId = $workoutInfo["userid"];
// Check that user of the workout_id_prev matches that of the cookie userid
if ($userid != $workoutUserId) {
    header('HTTP/1.1 500 Internal Server Error');
} else {
    $workoutLoggingService->deleteWorkout($workoutId);
    //update records table
    include 'update-records-absolute.php';
}
Example #2
0
$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;
$workout_info["TR_points"] = 300;
$workout_info["Lead_points"] = 400;
$userrecordDAO = new UserRecordsDAO();
var_dump($userrecordDAO->getUserRecords($userid));
$results = $WorkoutService->saveWorkoutAbsGrades($workout_info, $workout_segments_abs);
Example #3
0
<?php

include './core/bootstrap.php';
//connect to database
include 'dbconnect.php';
//check that user has a valid cookie, redirect if no valid cookie
include 'php_common/cookiecheck.php';
$workoutLoggingService = new WorkoutLoggingService();
$userService = new UserService();
$climbingAreaService = new ClimbingAreaService();
$workout_id_prev = $_GET['wid'];
$showChangesSaved = 0;
//check if edits have been submitted
if (isset($_POST['workoutsubmit'])) {
    // save workout as a new workout (even though it was edited)
    $workoutResult = $workoutLoggingService->saveWorkout($_POST, $userid);
    // delete the previous workout
    $workoutLoggingService->deleteWorkout($workout_id_prev);
    // reset previous workout id
    $workout_id_prev = $workoutResult["workoutID"];
    //display a message that changes have been saved.
    $showChangesSaved = 1;
    //update records table
    include 'update-records-absolute.php';
}
$workoutInfo = $workoutLoggingService->getWorkoutInfo($workout_id_prev);
$userid_wid = $workoutInfo["userid"];
// Check that user of the workout_id_prev matches that of the cookie userid
if ($userid != $userid_wid) {
    header('Location: past-workouts.php');
}
Example #4
0
<?php

include "./core/bootstrap.php";
include 'dbconnect.php';
//check that user has a valid cookie, redirect if no valid cookie
include 'php_common/cookiecheck.php';
//Read in submitted workout and write to workout tables
$userService = new UserService();
$climbingAreaService = new ClimbingAreaService();
$workoutLoggingService = new WorkoutLoggingService();
//check that register form is submitted
if (isset($_POST['workoutsubmit'])) {
    $workoutResult = $workoutLoggingService->saveWorkout($_POST, $userid);
    $boulder_points = $workoutResult["boulderPoints"];
    $tr_points = $workoutResult["trPoints"];
    $lead_points = $workoutResult["leadPoints"];
    $workoutdate = $workoutResult["workoutDate"];
} else {
    header("Location: workout-input.php");
}
?>
<!DOCTYPE HTML>
<html>
	<head>
		<title>Gym Climbing Tracker</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="icon" href="images/favicon.ico" type="image/x-icon">
		<!-- Latest compiled and minified CSS -->
		<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
		<link rel="stylesheet" type="text/css" href="style.php/mycss.scss">