From ffa11038700e34a2727b7e5b65b4ff4c5a1ade16 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC3NEC6\\chiefsoft" Date: Wed, 8 Feb 2023 20:15:57 -0500 Subject: [PATCH] gate updates --- app/Config/Routes.php | 4 ++ app/Controllers/Myfituser.php | 54 ++++++++++-------------- app/Models/myfitResources.php | 58 ++++++-------------------- app/Models/myfitTracking.php | 68 +++++++++++++++++++++++++------ app/Models/myfitUserReminders.php | 5 ++- 5 files changed, 98 insertions(+), 91 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 4aa0d7e..2c215bd 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -62,6 +62,7 @@ $routes->get('/en/desktop/api/v2/myfituser/tracking', 'Myfituser::users'); // REMINDERS ------------------------------------------------------------- +$routes->get('/en/desktop/api/v2/myfituser/reminders?(:any)', 'Myfituser::users/$1'); $routes->get('/en/desktop/api/v2/myfituser/reminders', 'Myfituser::users'); $routes->get('/en/desktop/api/v2/myfituser/remcategory', 'Myfituser::users'); $routes->get('/en/desktop/api/v2/myfituser/remmode', 'Myfituser::users'); @@ -70,6 +71,9 @@ $routes->post('/en/desktop/api/v2/myfituser/editreminder', 'Myfituser::users'); $routes->get('/en/desktop/api/v2/myfituser/calendar', 'Myfituser::users'); $routes->get('/en/desktop/api/v2/myfituser/loginhx', 'Myfituser::users'); $routes->get('/en/desktop/api/v2/myfituser/stats', 'Myfituser::users'); +$routes->get('/en/desktop/api/v2/myfituser/resources', 'Myfituser::users'); + +$routes->get('/en/desktop/api/v2/myfituser/trackcategory', 'Myfituser::users'); //MYFIT DESKTOP USERS $routes->post('/en/mobile/api/v2/myfituser/login', 'Myfituser::users'); diff --git a/app/Controllers/Myfituser.php b/app/Controllers/Myfituser.php index e744cec..212c187 100644 --- a/app/Controllers/Myfituser.php +++ b/app/Controllers/Myfituser.php @@ -32,7 +32,13 @@ class Myfituser extends BaseController header('Content-type: application/json'); // what is the endpoint - $uri = current_url(true); + $uri = urldecode(current_url(true)); + $findme = '?'; + $pos = strpos($uri, $findme); + if ($pos > 5) { + $uri = substr($uri, 0, $pos); + } + $pieces = explode('/', $uri); $psc = count($pieces); @@ -50,50 +56,30 @@ class Myfituser extends BaseController 'stats' => ['GET'], 'remcategory' => ['GET'], 'remmode' => ['GET'], + 'resources' => ['GET'], + 'trackcategory' => ['GET'] ]; - // Retrieve an HTTP Request header, with case-insensitive names - // $header_host = $this->request->getHeader('host'); - $content_type = $this->request->getHeader('Content-Type'); - // Retrieve JSON from AJAX calls - $hhost = $this->request->getServer('Host'); - // Retrieve an HTTP Request header, with case-insensitive names - // $request->getHeader('host'); - //$au = $this->request->getHeader('Authorization'); - $res1 = []; if (array_key_exists($endpoint, $endpoints)) { } else { http_response_code(404); // tell the user product does not exist - echo json_encode(['message' => 'Endpoint not found.']); + echo json_encode([ + 'message' => 'Endpoint not found.', + 'URI' => $uri, + ]); } // echo "EXYTACT INPUT DATA HERE"; $raw_json = file_get_contents('php://input'); $raw_array = json_decode($raw_json, true); - //$raw_array['au'] =$au; - // $raw_array['host'] = $header_host; - - $raw_array['getitem'] = $this->request->getJSON(); - $raw_array['content_type'] = $content_type; - $raw_array['hhost'] = $hhost; if ($_SERVER['REQUEST_METHOD'] == 'GET') { - $opts = [ - 'http' => [ - 'method' => 'GET', - ], - ]; - - $context = stream_context_create($opts); - - // Open the file using the HTTP headers set above - $raw_json = file_get_contents('php://input', false, $context); - $raw_array = json_decode($raw_json, true); - // $raw_array = ['abcdef']; + $get_param = $_GET['reqData'] ?? null; + $raw_array = json_decode($get_param, true); } - // $raw_array = json_decode($this->request->getJSON(), true); + // $raw_array['fff'] = json_decode($this->request->getJSON(), true); switch ($endpoint) { case 'login': @@ -120,8 +106,8 @@ class Myfituser extends BaseController $res1 = $myfitUserReminders->reminderAddEdit($raw_array); break; case 'resources': - $myfiResources = new \App\Models\myfiResources(); - $res1 = $myfiResources->getSiteResources($raw_array); + $myfitResources = new \App\Models\myfitResources(); + $res1 = $myfitResources->getSiteResources($raw_array); break; case 'myfeed': $res1 = $this->dummyData($raw_array); @@ -139,6 +125,10 @@ class Myfituser extends BaseController $myfitHx = new \App\Models\myfitHx(); $res1 = $myfitHx->readLoginHx($raw_array); break; + case 'trackcategory': + $myfitTracking = new \App\Models\myfitTracking(); + $res1 = $myfitTracking->getTrackCategory(); + break; } return $this->response->setJson($res1); diff --git a/app/Models/myfitResources.php b/app/Models/myfitResources.php index 8217970..511f37e 100644 --- a/app/Models/myfitResources.php +++ b/app/Models/myfitResources.php @@ -12,52 +12,20 @@ class myfitResources extends Model public function getSiteResources($in) { + $dm = []; + for ($i = 1; $i <= 9; $i++) { + $ar = [ + 'id' => $i, + 'description' => "This is the $i Desc $i", + 'img1' => 'https://blog.mermsemr.com/wp-content/uploads/2021/01/COVID-19-vaccine_002.jpg', + ]; + + $dm[] = $ar; + } + return [ - 'pricing_text_02' => 'This will be the test header test 001', - 'pricing' => [ - [ - 'icon' => '/static/media/standard.png', - 'title' => 'Standard', - 'text' => 'For the basics.', - 'price' => 'Free', - 'price_anual' => 'Free', - 'features' => [ - 'Reminders', - 'Health Tracking', - 'Analytics', - 'Notifications', - 'Health Resources', - ], - ], - [ - 'icon' => '/static/media/unlimited.png', - 'title' => 'Unlimited', - 'text' => 'Professionals here.', - 'price' => '$7.99/m', - 'price_anual' => '$55/y', - 'features' => [ - 'Everyting Premium', - 'Feature 22', - 'Feature 33', - 'Integrations', - 'Custom Page', - ], - ], - [ - 'icon' => '/static/media/premium.png', - 'title' => 'Premium', - 'text' => 'For small team.', - 'price' => '$5/m', - 'price_anual' => '$45/y', - 'features' => [ - 'Everything Standard', - 'Group/Family Tracking', - 'Custom Dashboard', - 'Recomendations', - 'Storage', - ], - ], - ], + 'resources' => $dm, + 'raw_data' => $in, ]; } } diff --git a/app/Models/myfitTracking.php b/app/Models/myfitTracking.php index 7bfdfc6..0489e27 100644 --- a/app/Models/myfitTracking.php +++ b/app/Models/myfitTracking.php @@ -11,16 +11,64 @@ class myfitTracking extends Model public function __construct() { parent::__construct(); - //$db = \Config\Database::connect('mermsemr'); $this->db = \Config\Database::connect($this->con_name); } + public function getTrackCategory() + { + $cat = []; + $i=1; + $itArr = [ + 'id' => $i, + 'uid' => '1234-5678-90777-0000' . $i, + 'title' => 'Weight', + 'widget' => 't-weight', + 'profile_img' => 'weight.jpg', + 'thumbnil' => 'weight.png', + ]; + $cat[] = $itArr; + + $i=2; + $itArr = [ + 'id' => $i, + 'uid' => '1234-5678-90777-0000' . $i, + 'title' => 'Exercise', + 'widget' => 't-weight', + 'profile_img' => 'weight.jpg', + 'thumbnil' => 'exercise.png', + ]; + $cat[] = $itArr; + + $i=3; + $itArr = [ + 'id' => $i, + 'uid' => '1234-5678-90777-0000' . $i, + 'title' => 'Activity', + 'widget' => 't-weight', + 'profile_img' => 'weight.jpg', + 'thumbnil' => 'activity.png', + ]; + $cat[] = $itArr; + + + for ($i = 4; $i < 9; $i++) { + $itArr = [ + 'id' => $i, + 'uid' => '1234-5678-90777-0000' . $i, + 'title' => 'Some Title ' . $i, + 'widget' => 't-weight', + 'profile_img' => 'profile.png', + 'thumbnil' => 'tranding-2.jpg', + ]; + $cat[] = $itArr; + } + return $cat; + } + public function readTracking($in) { - $sqlQ = - 'SELECT * FROM members_reminders'; + $sqlQ = 'SELECT * FROM members_reminders'; - $query = $this->db->query($sqlQ); $data['reminders_data'] = $query->getResultArray(); return $inx = [ @@ -28,19 +76,15 @@ class myfitTracking extends Model 'status' => 1, 'raw_data' => $in, ]; - - } - public function getSupportedTrackingDevices(){ - + public function getSupportedTrackingDevices() + { return []; } - public function userConfigureDevice(){ - + public function userConfigureDevice() + { return []; } - - } diff --git a/app/Models/myfitUserReminders.php b/app/Models/myfitUserReminders.php index 4ca718c..63882b7 100644 --- a/app/Models/myfitUserReminders.php +++ b/app/Models/myfitUserReminders.php @@ -17,9 +17,10 @@ class myfitUserReminders extends Model public function readReminders($in) { $member_id = - isset($in['member_id']) && $in['member_id'] > 0 - ? $in['member_id'] + (isset($in['member_id']) && (int)$in['member_id'] > 0) + ? (int)$in['member_id'] : 0; + //$member_id=16; // for testing $reminder_category = $this->reminderCategory(); // []; $sqlQ = "SELECT * FROM members_reminders WHERE member_id = $member_id"; $query = $this->db->query($sqlQ);