diff --git a/www-api/app/Controllers/WrenchApi.php b/www-api/app/Controllers/WrenchApi.php index 9b8f5849..549a092b 100644 --- a/www-api/app/Controllers/WrenchApi.php +++ b/www-api/app/Controllers/WrenchApi.php @@ -464,10 +464,10 @@ class WrenchApi extends BaseController 'URI' => $uri, ]); } - + $local_out =[]; if ($_SERVER["REQUEST_METHOD"] == "POST") { if ( $endpoint == 'uploads'){ - $local_out=["test_msg"=>'Yes the upload endpoinmt was hit********']; + $local_out=["test_msg"=>'Yes the upload endpoint was hit********']; $call_backend = false; // will be decided after file is saved } if (isset($_FILES) && is_array($_FILES) && count($_FILES)>0) { @@ -488,7 +488,7 @@ class WrenchApi extends BaseController log_message('critical', "wrenchboard_api-CALL RAW DATA".serialize($raw_array) ); //-- move to another module start - $local_out =[]; + $in["loc"] = $_SERVER["REMOTE_ADDR"]; $in = $this->prepareEndPointData($endpoint, $raw_array,$call_backend,$local_out); log_message('critical', "wrenchboard_api-CALL PREPARE DATA".serialize($in) ); @@ -498,277 +498,14 @@ class WrenchApi extends BaseController $wrenchboard = new \App\Models\BackendModel(); $ret = $wrenchboard->wrenchboard_api($in, $out); $out['internal_return'] = $ret; - /* $this->load->model('BackendModel'); - $out = array(); - //$ret = $this->BackendModel->wrenchboard_api($in, $out); - // $wrenchboard = new \App\Models\BackendModel(); - // $ret = $wrenchboard->wrenchboard_api($in, $out); - $out['internal_return'] = 0; // $ret; // this is reserved array parameter - to be captured and received before you use the out array() - */ } - else - { - $out = $local_out; - } - - // $raw_array =[]; - // $out = $this->dummyData($in); - //return $this->response->setJson($res1); - return json_encode( ( new \App\Models\ResultFormatter() )->processOutJson($in, $out)); - - } - public function apigateDELAY(){ -/* - //$request = service('request'); - 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 = urldecode(current_url(true)); - $findme = '?'; - $pos = strpos($uri, $findme); - if ($pos > 5) { - $uri = substr($uri, 0, $pos); - } - log_message('critical', "API-GATE URI -> ".$uri ); - - $pieces = explode('/', $uri); - $psc = count($pieces); - - $endpoint = $psc > 0 ? $pieces[$psc - 1] : ''; - log_message('critical', "Enpoint-> ".$endpoint ); - - $endpoints = $this->endPointList(); - - $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.', - 'URI' => $uri, - ]); - } - // echo "EXYTACT INPUT DATA HERE"; - $raw_json = file_get_contents('php://input'); - $raw_array = json_decode($raw_json, true); - - if ($_SERVER['REQUEST_METHOD'] == 'GET') { - log_message('critical', "Enpoint LOC2 HERE -> ".$endpoint ); - $get_param = $_GET['reqData'] ?? null; - $raw_array = ($get_param!=null) ? json_decode($get_param, true):[]; - } - - - //-- move to another module start - $call_backend = true; - $in["loc"] = $_SERVER["REMOTE_ADDR"]; - switch ($endpoint) { - case 'disableaccount': - $in['action'] = WRENCHBOARD_USER_DELETEACC; - break; - case 'replyinterestmessage': - $in["action"] = WRENCHBOARD_JOB_REPLY_QUESTION; - break; - case 'sendinterestmessage': - // $in['offer_code'] = $this->input->get('offer_code'); - $in['yourmessage'] = $in["question"]; - //$in['member_id'] = $_SESSION['member_id']; // just maing sure - $in['msg_type'] = 'JOB'; - // $in['action'] = WRENCHBOARD_JOB_SEND_QUESTION; - - $in["action"] = WRENCHBOARD_JOB_SEND_QUESTION; - break; - case 'couponredeem': - $in["action"] = WRENCHBOARD_COUPON_REDEEM; - break; - case 'couponpending': - $in["action"] = WRENCHBOARD_COUPON_PENDLIST; - break; - case 'couponhx': - $in["action"] = WRENCHBOARD_COUPON_MEMLIST; - break; - case 'signupcountry': - // checi if in cache if not read - $local_out = [ - 'result'=>'100', - 'signup_country'=>[ - ['NG', 'Nigeria'], - ['US', 'United States'] - ] - ]; - $call_backend = false; - break; -// case 'blogitem': -// $blogData = (new \App\Models\ResultFormatter() )->getBlogItem(); -// $local_out = [ -// 'result'=>'100', -// 'blog_data'=> $blogData -// ]; -// $call_backend = false; -// break; -// case 'blogdata': -// $blogData = (new \App\Models\ResultFormatter() )->getBlogData(); -// $local_out = [ -// 'result'=>'100', -// 'blog_data'=> $blogData -// ]; -// $call_backend = false; -// break; - case 'userscards': - $in["action"] = WRENCHBOARD_CARDS_GETCARDLIST; - $local_out = [ - 'result'=>'100', - 'result_list'=>[ - ['title'=>'This is your coupon', - 'description'=>'This is the description of the description', - 'card_type'=>'COUPON', - 'card_style' =>'card1', - 'card_icon' =>'icon1', - 'assign_id'=> 0, - 'Nigeria'], - ['title'=>'A Recommended Story', - 'description'=>'This is the description of the description', - 'card_type'=>'BLOG', - 'card_style' =>'card2', - 'card_icon' =>'icon1', - 'assign_id'=> 0, - 'United States'], - ['title'=>'You have a new task sent to you', - 'description'=>'This is the description of the description', - 'card_type'=>'NEWTASK', - 'card_style' =>'card1', - 'card_icon' =>'icon1', - 'assign_id'=> 0, - 'United States'], - ['title'=>'You just Earned some token', - 'description'=>'This is the description of the description', - 'card_type'=>'TOKEN', - 'card_style' =>'card2', - 'card_icon' =>'icon1', - 'assign_id'=> 0, - 'United States'] - ] - ]; - // $call_backend = false; - - break; - case 'myjobs': $in["action"] = WRENCHBOARD_ACCOUNT_JOBLIST; - break; - case 'sitecontact': - $local_out = ['result'=>'100','msg'=>'Received']; - $call_backend = false; - break; - case 'generics': - case 'apigate': - //$in["action"] = WRENCHBOARD_ACCOUNT_LOGIN; - break; - case 'startjoblist': $in["action"] = WRENCHBOARD_START_JOBLIST; - if (!array_key_exists("limit",$in)) $in["limit"] = 10; - if (!array_key_exists("page",$in)) $in["page"] = 1; - break; - - case 'createmobileuser': $in["action"] = WRENCHBOARD_CREATE_MOBILEUSER; - $in["loc"] = $_SERVER["REMOTE_ADDR"]; - $in["news"] = 0; - $in["terms"] = 1; - $in["mobile"] = "MOBILE"; - break; - case 'completemobileuser': $in["action"] = WRENCHBOARD_COMPLETE_MOBILEUSER; - $in["loc"] = $_SERVER["REMOTE_ADDR"]; - break; - - case 'startresetpasword': - $in["action"] = WRENCHBOARD_RESET_PASSWORD; - break; - case 'createuser': $in["action"] = WRENCHBOARD_ACCOUNT_PENDING; - $in["street1"] = $in["streetaddress"]; - $in["zipcode"] = $in["zip"]; - $in["country"] = "US"; - $in["loc"] = $_SERVER["REMOTE_ADDR"]; - $in["mobile"] = "MOBILE"; - break; - case 'activejoblist': $in["action"] = WRENCHBOARD_MOBILE_ACTIVEJOB; - break; - case 'message': $in["action"] = WRENCHBOARD_MOBILE_MESSAGE; - - break; - case 'paymenthx': $in["action"] = WRENCHBOARD_MOBILE_PAYMENTHX; - - break; - case 'getjobsdata': $in["action"] = WRENCHBOARD_ACCOUNT_JOBLIST; - break; - - case 'userlogin': $in["action"] = WRENCHBOARD_ACCOUNT_LOGIN; - $in["login_mode"] = MOBILE_LOGIN; - break; - - case 'dashdata': $in["action"] = WRENCHBOARD_ACCOUNT_DASHDATA; - break; - case 'offerslist': $in["action"] = WRENCHBOARD_MOBILE_OFFERSLIST; - break; - - case 'loadprofile': $in["action"] = WRENCHBOARD_MOBILE_LOADPROFILE; - break; - case 'account': $in["action"] = WRENCHBOARD_MOBILE_ACCOUNT; - break; - case 'getpendingjobs': - $in["action"] = WRENCHBOARD_ACCOUNT_PENDJOB; - break; - case 'pendingjob': - - break; - case 'getjob': - - break; - - case 'mybanklist':$in["action"] = WRENCHBOARD_USER_GETBANKLIST; - break; - case 'sendmoney':$in["action"] = WRENCHBOARD_USER_SENDMONEY; - $out["internal_return"] = 0; - break; - case 'sendinterest':$in["action"] = WRENCHBOARD_USER_SENDJOBINT; - $out["internal_return"] = 0; - break; - case 'sendmoneyfee': $in["action"] = WRENCHBOARD_SMONEY_PROCFEE; - break; - case 'taskmessage': $in["action"] = WRENCHBOARD_MOBILE_TASKMESSAGE; - break; - case 'sendtaskmessage': $in["action"] = WRENCHBOARD_MOBILE_SENDTASKMESSAGE; - break; - - case 'getwallets': $in["action"] = WRENCHBOARD_ACCOUNT_WALLETS; - break; - } - //-- move to another module end - - $in["pid"] = 100; - $out = array(); - if ( $call_backend == true){ - - $this->load->model('BackendModel'); - $out = array(); - //$ret = $this->BackendModel->wrenchboard_api($in, $out); - - - // $wrenchboard = new \App\Models\BackendModel(); - // $ret = $wrenchboard->wrenchboard_api($in, $out); - $out['internal_return'] = 0; // $ret; // this is reserved array parameter - to be captured and received before you use the out array() } else { $out = $local_out; } - //ResultFormatter return json_encode( ( new \App\Models\ResultFormatter() )->processOutJson($in, $out)); - // $res1 = $this->dummyData($raw_array); - // return $this->response->setJson($res1); + } private function dummyData($raw_array) diff --git a/www-api/public/svs/user/userve.php b/www-api/public/svs/user/userve.php index 5b234f7b..12f2dd52 100755 --- a/www-api/public/svs/user/userve.php +++ b/www-api/public/svs/user/userve.php @@ -134,7 +134,7 @@ if (array_search($_SERVER['REQUEST_METHOD'], $methods) === false) { if ($_SERVER["REQUEST_METHOD"] == "POST") { if ( $endpoint == 'uploads'){ - $local_out=["test_msg"=>'Yes the upload endpoinmt was hit******** 777']; + $local_out=["test_msg"=>'Yes the upload endpoint was hit******** 777']; $call_backend = false; // will be decided after file is saved } $call_backend = false;