gate updates

This commit is contained in:
2023-02-08 20:15:57 -05:00
parent 9e21a2980e
commit ffa1103870
5 changed files with 98 additions and 91 deletions
+22 -32
View File
@@ -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);