-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfitlogupdate.php
More file actions
executable file
·122 lines (107 loc) · 4.01 KB
/
fitlogupdate.php
File metadata and controls
executable file
·122 lines (107 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
/* File: fitlogupdate.php
Desciption: Implementation file for the updating/deleting of workouts.
Author: Eric A. Bonney
Date: February 6, 2009
Updated: February 17, 2009
*/
require_once( '../../../wp-blog-header.php' );
require_once( '../../../wp-load.php');
global $wpdb;
global $userdata;
get_currentuserinfo();
$date_edited = $_GET["edit_date"];
//Start a new session or find an existing one.
session_start();
// Let's pull the day that the user has selected to edit/update from the flmain table.
$query = "SELECT * FROM " . $wpdb->prefix . "flmain WHERE workout_date='" . $date_edited . "' AND user_id=" . $userdata->ID;
// Let's pull the day that the user has selected to edit/update from the flblog table
$query2 = "SELECT * FROM " . $wpdb->prefix . "flblog WHERE blog_date='" . $date_edited . "' AND user_id=" . $userdata->ID;
// Let's pull the day that the user has selected to edit/update from the flstrength table
$query3 = "SELECT * FROM " . $wpdb->prefix . "flstrength WHERE workout_date='" . $date_edited . "' AND user_id=" . $userdata->ID;
// Run the two queries.
$results = $wpdb->get_results( $query, ARRAY_A );
$results_blog = $wpdb->get_results( $query2, ARRAY_A );
$results_strength = $wpdb->get_results( $query3, ARRAY_A );
$_SESSION["date_updated"] = $date_edited;
//If we have any data,then store it in a session, if not just set the session for the workout date selected.
if( $results )
{
// Now store the day to be edited inside a session
foreach( $results as $row )
{
switch( $row["sbr_type"] )
{
case "s":
$_SESSION["s_workoutdate"] = $row["workout_date"];
$_SESSION["s_workouttime"] = $row["time_of_day"];
$_SESSION["s_duration"] = $row["duration"];
$_SESSION["s_distance"] = $row["distance"];
$_SESSION["s_pace"] = $row["pace"];
$_SESSION["s_minhr"] = $row["min_hr"];
$_SESSION["s_avghr"] = $row["avg_hr"];
$_SESSION["s_maxhr"] = $row["max_hr"];
$_SESSION["s_calsburned"] = $row["cals_burned"];
$_SESSION["s_notes"] = $row["notes"];
$_SESSION["s_sbr_type"] = "s";
$_SESSION["s_plan_type"] = "a";
break;
case "b":
$_SESSION["b_workoutdate"] = $row["workout_date"];
$_SESSION["b_workouttime"] = $row["time_of_day"];
$_SESSION["b_duration"] = $row["duration"];
$_SESSION["b_distance"] = $row["distance"];
$_SESSION["b_pace"] = $row["pace"];
$_SESSION["b_avgrpms"] = $row["avg_rpms"];
$_SESSION["b_minhr"] = $row["min_hr"];
$_SESSION["b_avghr"] = $row["avg_hr"];
$_SESSION["b_maxhr"] = $row["max_hr"];
$_SESSION["b_calsburned"] = $row["cals_burned"];
$_SESSION["b_notes"] = $row["notes"];
$_SESSION["b_sbr_type"] = "b";
$_SESSION["s_plan_type"] = "a";
break;
case "r":
$_SESSION["r_workoutdate"] = $row["workout_date"];
$_SESSION["r_workouttime"] = $row["time_of_day"];
$_SESSION["r_duration"] = $row["duration"];
$_SESSION["r_distance"] = $row["distance"];
$_SESSION["r_pace"] = $row["pace"];
$_SESSION["r_minhr"] = $row["min_hr"];
$_SESSION["r_avghr"] = $row["avg_hr"];
$_SESSION["r_maxhr"] = $row["max_hr"];
$_SESSION["r_calsburned"] = $row["cals_burned"];
$_SESSION["r_notes"] = $row["notes"];
$_SESSION["r_sbr_type"] = "r";
$_SESSION["s_plan_type"] = "a";
break;
}
}
$_SESSION["updating"] = true;
}
else
$_SESSION["updating"] = false;
if( $results_blog )
{
// Now store the day to be edited inside a session
foreach( $results_blog as $row )
$_SESSION["blog_notes"] = $row["notes"];
$_SESSION["updating"] = true;
}
if( $results_strength )
{
// Now store the day to be edited inside a session
foreach( $results_strength as $row )
{
$_SESSION["str_exercises_id"] = $row["exercises_id"];
$_SESSION["str_workoutdate"] = $row["workout_date"];
$_SESSION["str_workouttime"] = $row["time_of_day"];
$_SESSION["str_duration"] = $row["duration"];
$_SESSION["str_notes"] = $row["notes"];
}
$_SESSION["updating"] = true;
}
// re-direct to the actual form.
$url = get_bloginfo(wpurl) . "/wp-admin/admin.php?page=fitnesslog-workouts";
wp_redirect($url);
?>