From 3bd5ea445ab88d15119ffed426c4728e56f1f7a1 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC3NEC6\\chiefsoft" Date: Sat, 21 Jan 2023 19:08:51 -0500 Subject: [PATCH] Clean up --- .INFO | 15 +++ app/Config/Database.php | 39 ++++++++ app/Config/Routes.php | 7 +- app/Controllers/Myfituser.php | 164 +++++++++++++++++++++++++++++++++ docker-compose.yml | 2 +- docker/apache/000-default.conf | 2 +- 6 files changed, 225 insertions(+), 4 deletions(-) create mode 100644 .INFO create mode 100644 app/Controllers/Myfituser.php diff --git a/.INFO b/.INFO new file mode 100644 index 0000000..43414ad --- /dev/null +++ b/.INFO @@ -0,0 +1,15 @@ + +MYSQL SET UP +SET GLOBAL validate_password.length = 8; +SET GLOBAL validate_password.policy=LOW; + +CREATE DATABASE site_mermsemr_com; +CREATE USER 'mermsemr'@'192.168.%' IDENTIFIED BY 'may12002'; +GRANT ALL PRIVILEGES ON site_mermsemr_com.* TO 'mermsemr'@'192.168.%'; + +https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql + + + +SELECT User, Host, plugin FROM mysql.user; + diff --git a/app/Config/Database.php b/app/Config/Database.php index f1901e5..d97f0fc 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -50,6 +50,45 @@ class Database extends Config 'port' => 3306, ]; + public $mermsemr_blog = [ + 'DSN' => '', + 'hostname' => '10.10.33.60', + 'username' => 'mermsemr', + 'password' => 'may12002', + 'database' => 'blog_mermsemr_com', + 'DBDriver' => 'MySQLi', + 'DBPrefix' => '', + 'pConnect' => false, + 'DBDebug' => (ENVIRONMENT !== 'production'), + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 3306, + ]; + + public $mermsemr_site = [ + 'DSN' => '', + 'hostname' => '10.10.33.60', + 'username' => 'mermsemr', + 'password' => 'may12002', + 'database' => 'site_mermsemr_com', + 'DBDriver' => 'MySQLi', + 'DBPrefix' => '', + 'pConnect' => false, + 'DBDebug' => (ENVIRONMENT !== 'production'), + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 3306, + ]; /** diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f1855c3..49bfaf3 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -48,8 +48,11 @@ $routes->post('/en/desktop/api/v2/myfit/contact', 'Myfit::contact'); $routes->get('/en/desktop/api/v2/myfit/pricing', 'Myfit::pricing'); //MYFIT USERS -$routes->post('/en/desktop/api/v2/myfituser/login', 'Myfituser::login'); -$routes->post('/en/desktop/api/v2/myfituser/account', 'Myfituser::account'); +$routes->post('/en/desktop/api/v2/myfituser/login', 'Myfituser::users'); +$routes->post('/en/desktop/api/v2/myfituser/account', 'Myfituser::users'); + +$routes->get('/en/desktop/api/v2/myfituser/profile', 'Myfituser::users'); +$routes->get('/en/desktop/api/v2/myfituser/myfeed', 'Myfituser::users'); /* https://devapi.mermsemr.com/en/desktop/api/v2/myfit/country GET diff --git a/app/Controllers/Myfituser.php b/app/Controllers/Myfituser.php new file mode 100644 index 0000000..2636003 --- /dev/null +++ b/app/Controllers/Myfituser.php @@ -0,0 +1,164 @@ +request = $request = \Config\Services::request(); + } + + + public function index() + { + header("Access-Control-Allow-Origin: * "); + //header("Access-Control-Allow-Origin: http://localhost:9057 "); + header("Access-Control-Expose-Headers: Access-Control-Allow-Origin"); + header("Access-Control-Allow-Credentials: true "); + //header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With"); + header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS"); + header('Content-type: application/json'); + + $mBlogData = new \App\Models\myfitBlogData(); + $res1 = $mBlogData->getBlogData([]); + return $this->response->setJson($res1); + } + + public function users() + { + header("Access-Control-Allow-Origin: * "); + //header("Access-Control-Allow-Origin: http://localhost:9057 "); + header("Access-Control-Expose-Headers: Access-Control-Allow-Origin"); + header("Access-Control-Allow-Credentials: true "); + //header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With"); + header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS"); + header('Content-type: application/json'); + + + // what is the endpoint + $uri = current_url(true); + $pieces = explode("/", $uri); + $psc = count($pieces); + + $endpoint = ( $psc > 0) ? $pieces[ $psc-1] : ''; + + $endpoints = array( + 'createuser' => array('POST'), + 'userlogin' => array('POST'), + ); + + + if(array_key_exists( $endpoint, $endpoints)){ + // echo "EXYTACT INPUT DATA HERE"; + } + else{ + http_response_code(404); + // tell the user product does not exist + echo json_encode(array("message" => "Product does not exist.")); + } + + + $raw_json = file_get_contents("php://input"); + $raw_array = json_decode($raw_json, true); + $something = $raw_array["name"]; + + $inx = [ + 'message_id' => rand(100, 8888) . 'gsgsgsgsg-sssfsgggsgs-ususususu', + 'status'=>1, + 'endpoint'=>$endpoint, + 'raw_data'=> $raw_array + ]; + return $this->response->setJson($inx); + } + + + public function blogdata() + { + /* header("Access-Control-Allow-Origin: *"); + //header("x-devicetoken : *"); + //header("Authorization : Token"); + header("Access-Control-Expose-Headers: Access-Control-Allow-Origin"); + header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With,x-session-id, client_id, x-float-device-location-latitude, x-float-device-location-longitude, x-devicetoken"); + header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS"); + header('Content-type: application/json'); + Access-Control-Allow-Origin + + header1 = ('Access-Control-Allow-Credentials','true') + header2 = ('Access-Control-Allow-Origin', 'https://serviceview.example.com') + +*/ + header("Access-Control-Allow-Origin: * "); + //header("Access-Control-Allow-Origin: http://localhost:9057 "); + header("Access-Control-Expose-Headers: Access-Control-Allow-Origin"); + header("Access-Control-Allow-Credentials: true "); + //header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With"); + header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS"); + header('Content-type: application/json'); + + $mBlogData = new \App\Models\myfitBlogData(); + $res1 = $mBlogData->getBlogData([]); + return $this->response->setJson($res1); + // $this->setGetReturn(res1); + } + + public function country() + { + //header("Access-Control-Allow-Origin: http://localhost:9057 "); + header("Access-Control-Allow-Origin: * "); + header("Access-Control-Expose-Headers: Access-Control-Allow-Origin"); + header("Access-Control-Allow-Credentials: true "); + //header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With"); + header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS"); + header('Content-type: application/json'); + + $mCountry = new \App\Models\myfitCountry(); + return $this->response->setJson($mCountry->getSiteCountries([])); + } + + public function faq() + { + //header("Access-Control-Allow-Origin: http://localhost:9057 "); + header("Access-Control-Allow-Origin: * "); + header("Access-Control-Expose-Headers: Access-Control-Allow-Origin"); + header("Access-Control-Allow-Credentials: true "); + //header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With"); + header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS"); + header('Content-type: application/json'); + + $mFaq = new \App\Models\myfitFaqData(); + return $this->response->setJson($mFaq->getSiteFaq([])); + } + + public function pricing() + { + //header("Access-Control-Allow-Origin: http://localhost:9057 "); + header("Access-Control-Allow-Origin: * "); + header("Access-Control-Expose-Headers: Access-Control-Allow-Origin"); + header("Access-Control-Allow-Credentials: true "); + //header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With"); + header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS"); + header('Content-type: application/json'); + + $mPricing = new \App\Models\myfitPricing(); + return $this->response->setJson($mPricing->getSitePricing([])); + } + + private function setGetReturn($resp){ + header("Access-Control-Allow-Origin: * "); + //header("Access-Control-Allow-Origin: http://localhost:9057 "); + header("Access-Control-Expose-Headers: Access-Control-Allow-Origin"); + header("Access-Control-Allow-Credentials: true "); + //header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With"); + header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS"); + header('Content-type: application/json'); + return $this->response->setJson($resp); + } +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 227e502..17f1184 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,6 @@ services: - ./:/var/www/html - ./apache_log:/var/log/apache2 ports: - - 5102:80 + - 7035:80 volumes: src: \ No newline at end of file diff --git a/docker/apache/000-default.conf b/docker/apache/000-default.conf index 8533da8..7b5f392 100644 --- a/docker/apache/000-default.conf +++ b/docker/apache/000-default.conf @@ -1,6 +1,6 @@ ServerAdmin works@chiefsoft.com - ServerName blogdata.chiefsoft.com + ServerName blogdata.mermsemr.com DocumentRoot /var/www/html/public