Fleet Users login
This commit is contained in:
@@ -9,79 +9,6 @@ use CodeIgniter\API\ResponseTrait;
|
|||||||
class FloatFleetWeb extends BaseController
|
class FloatFleetWeb extends BaseController
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
|
||||||
|
|
||||||
|
|
||||||
public $con_name = 'float_blog';
|
|
||||||
private function apiData() {
|
|
||||||
$this->db = \Config\Database::connect($this->con_name);
|
|
||||||
$data = array();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$mysql = "SELECT id, post_title, post_content,post_date,comment_count FROM wp_posts WHERE post_type='post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 9";
|
|
||||||
$mysql = "SELECT p1.id AS id, p1.*, wm2.meta_value FROM wp_posts p1 LEFT JOIN wp_postmeta wm1
|
|
||||||
ON (wm1.post_id = p1.id AND wm1.meta_value IS NOT NULL AND wm1.meta_key = '_thumbnail_id' )
|
|
||||||
LEFT JOIN
|
|
||||||
wp_postmeta wm2
|
|
||||||
ON (wm1.meta_value = wm2.post_id AND wm2.meta_key = '_wp_attached_file' AND wm2.meta_value IS NOT NULL )
|
|
||||||
WHERE
|
|
||||||
p1.post_status='publish'
|
|
||||||
AND p1.post_type='post'
|
|
||||||
ORDER BY p1.post_date DESC LIMIT 30";
|
|
||||||
|
|
||||||
//echo $mysql;
|
|
||||||
|
|
||||||
$query = $this->db->query($mysql);
|
|
||||||
|
|
||||||
// $row = $query->result_array();
|
|
||||||
|
|
||||||
// $data["blog_array"] = $row;
|
|
||||||
$data['payload']['blogdata'] = $query->getResult('array');
|
|
||||||
$data['payload']['featured'] = [];
|
|
||||||
} catch (Exception $ex) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// featured
|
|
||||||
// try {
|
|
||||||
// $mysql = "SELECT id, post_title, post_content,post_date,comment_count
|
|
||||||
// FROM wp_posts WHERE post_type='post' AND post_status = 'publish' AND id = 263";
|
|
||||||
// $query = $this->db->query($mysql);
|
|
||||||
//
|
|
||||||
// $rowF = $query->result_array();
|
|
||||||
// // print_r( $rowF );
|
|
||||||
// // $r = $this->db->query($mysql);
|
|
||||||
// $data["blog_featured"] = $rowF[0];
|
|
||||||
// } catch (Exception $ex) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $this->renderSitePage('blog', $data);
|
|
||||||
// return $this->response->setJson($data);
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function blogData($endpoint,$raw_array)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
$rawData = $this->apiData();
|
|
||||||
// $res1= $rawData[0]['payload'];
|
|
||||||
$res1= $rawData; //[0]['payload'];
|
|
||||||
$this->saveCache('blogdata',$res1['payload']);
|
|
||||||
*/
|
|
||||||
|
|
||||||
$res1 = $this->getCache($endpoint);
|
|
||||||
if (count($res1)==0){
|
|
||||||
$rawData = $this->apiData();
|
|
||||||
$res1= $rawData['payload']; //[0]['payload'];
|
|
||||||
$this->saveCache($endpoint,$res1);
|
|
||||||
}
|
|
||||||
//$resJson = $this->response->setJson($res1);
|
|
||||||
return $res1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -112,9 +39,7 @@ class FloatFleetWeb extends BaseController
|
|||||||
log_message('critical', "Enpoint-> ".$endpoint );
|
log_message('critical', "Enpoint-> ".$endpoint );
|
||||||
|
|
||||||
$endpoints = [
|
$endpoints = [
|
||||||
'faq' => ['GET'],
|
'login' => ['POST']
|
||||||
'blogdata' => ['GET'],
|
|
||||||
'contact' => ['POST']
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$res1 = [];
|
$res1 = [];
|
||||||
@@ -140,16 +65,9 @@ class FloatFleetWeb extends BaseController
|
|||||||
// $raw_array['fff'] = json_decode($this->request->getJSON(), true);
|
// $raw_array['fff'] = json_decode($this->request->getJSON(), true);
|
||||||
log_message('critical', "Enpoint LOC2-> ".$endpoint );
|
log_message('critical', "Enpoint LOC2-> ".$endpoint );
|
||||||
switch ($endpoint) {
|
switch ($endpoint) {
|
||||||
case 'faq':
|
case 'login':
|
||||||
$res1 = (new \App\Models\faqData())->getSiteFaq([]);
|
$res1 = $this->dummyData($raw_array);
|
||||||
break;
|
break;
|
||||||
case 'blogdata':
|
|
||||||
$res1 = $this->blogData($endpoint,$raw_array);
|
|
||||||
break;
|
|
||||||
case 'contact':
|
|
||||||
$res1 = $this->contact($raw_array);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response->setJson($res1);
|
return $this->response->setJson($res1);
|
||||||
@@ -164,77 +82,5 @@ class FloatFleetWeb extends BaseController
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function contact($raw_array)
|
|
||||||
{
|
|
||||||
/*$inx = array(
|
|
||||||
'name' => $this->post('name'),
|
|
||||||
'email' => $this->post('email'),
|
|
||||||
'country' => $this->post('country'),
|
|
||||||
'phone' => $this->post('phone'),
|
|
||||||
'message' => $this->post('message')
|
|
||||||
);
|
|
||||||
$something = $this->request->getVar('name');
|
|
||||||
*/
|
|
||||||
// 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');
|
|
||||||
$startInsert = false;
|
|
||||||
$status = 0;
|
|
||||||
$message_id = '';
|
|
||||||
// $raw_json = file_get_contents('php://input');
|
|
||||||
// $raw_array = json_decode($raw_json, true);
|
|
||||||
// $something = $raw_array['name'];
|
|
||||||
|
|
||||||
$db = \Config\Database::connect('float_site');
|
|
||||||
if (
|
|
||||||
$raw_array['country'] != '' &&
|
|
||||||
$raw_array['email'] != '' &&
|
|
||||||
$raw_array['name'] != '' &&
|
|
||||||
$raw_array['message'] != '' &&
|
|
||||||
$raw_array['phone'] != ''
|
|
||||||
) {
|
|
||||||
$startInsert = true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$status = -2;
|
|
||||||
$message_id = 'Parameters not recieved';
|
|
||||||
}
|
|
||||||
$data = [
|
|
||||||
'country' => $raw_array['country'],
|
|
||||||
'email' => $raw_array['email'],
|
|
||||||
'name' => $raw_array['name'],
|
|
||||||
'message' => $raw_array['message'],
|
|
||||||
'phone' => $raw_array['phone'],
|
|
||||||
];
|
|
||||||
|
|
||||||
if ($startInsert) {
|
|
||||||
try {
|
|
||||||
$db->table('myfit_contact')->insert($data);
|
|
||||||
// $insert_id = $db->affectedRows();
|
|
||||||
$insert_id = $db->insertId();
|
|
||||||
$query = $db->query(
|
|
||||||
'SELECT uuid, id FROM myfit_contact WHERE id = ' .
|
|
||||||
$insert_id
|
|
||||||
);
|
|
||||||
$row = $query->getRow();
|
|
||||||
$message_id = $row->uuid;
|
|
||||||
$status = $row->id;
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$status = -1;
|
|
||||||
$message_id = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$inx = [
|
|
||||||
'message_id' => $message_id,
|
|
||||||
'status' => $status,
|
|
||||||
];
|
|
||||||
return $inx;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,78 +10,6 @@ class FloatUserWeb extends BaseController
|
|||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
|
||||||
|
|
||||||
|
|
||||||
public $con_name = 'float_blog';
|
|
||||||
private function apiData() {
|
|
||||||
$this->db = \Config\Database::connect($this->con_name);
|
|
||||||
$data = array();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$mysql = "SELECT id, post_title, post_content,post_date,comment_count FROM wp_posts WHERE post_type='post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 9";
|
|
||||||
$mysql = "SELECT p1.id AS id, p1.*, wm2.meta_value FROM wp_posts p1 LEFT JOIN wp_postmeta wm1
|
|
||||||
ON (wm1.post_id = p1.id AND wm1.meta_value IS NOT NULL AND wm1.meta_key = '_thumbnail_id' )
|
|
||||||
LEFT JOIN
|
|
||||||
wp_postmeta wm2
|
|
||||||
ON (wm1.meta_value = wm2.post_id AND wm2.meta_key = '_wp_attached_file' AND wm2.meta_value IS NOT NULL )
|
|
||||||
WHERE
|
|
||||||
p1.post_status='publish'
|
|
||||||
AND p1.post_type='post'
|
|
||||||
ORDER BY p1.post_date DESC LIMIT 30";
|
|
||||||
|
|
||||||
//echo $mysql;
|
|
||||||
|
|
||||||
$query = $this->db->query($mysql);
|
|
||||||
|
|
||||||
// $row = $query->result_array();
|
|
||||||
|
|
||||||
// $data["blog_array"] = $row;
|
|
||||||
$data['payload']['blogdata'] = $query->getResult('array');
|
|
||||||
$data['payload']['featured'] = [];
|
|
||||||
} catch (Exception $ex) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// featured
|
|
||||||
// try {
|
|
||||||
// $mysql = "SELECT id, post_title, post_content,post_date,comment_count
|
|
||||||
// FROM wp_posts WHERE post_type='post' AND post_status = 'publish' AND id = 263";
|
|
||||||
// $query = $this->db->query($mysql);
|
|
||||||
//
|
|
||||||
// $rowF = $query->result_array();
|
|
||||||
// // print_r( $rowF );
|
|
||||||
// // $r = $this->db->query($mysql);
|
|
||||||
// $data["blog_featured"] = $rowF[0];
|
|
||||||
// } catch (Exception $ex) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $this->renderSitePage('blog', $data);
|
|
||||||
// return $this->response->setJson($data);
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function blogData($endpoint,$raw_array)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
$rawData = $this->apiData();
|
|
||||||
// $res1= $rawData[0]['payload'];
|
|
||||||
$res1= $rawData; //[0]['payload'];
|
|
||||||
$this->saveCache('blogdata',$res1['payload']);
|
|
||||||
*/
|
|
||||||
|
|
||||||
$res1 = $this->getCache($endpoint);
|
|
||||||
if (count($res1)==0){
|
|
||||||
$rawData = $this->apiData();
|
|
||||||
$res1= $rawData['payload']; //[0]['payload'];
|
|
||||||
$this->saveCache($endpoint,$res1);
|
|
||||||
}
|
|
||||||
//$resJson = $this->response->setJson($res1);
|
|
||||||
return $res1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -138,16 +66,9 @@ class FloatUserWeb extends BaseController
|
|||||||
// $raw_array['fff'] = json_decode($this->request->getJSON(), true);
|
// $raw_array['fff'] = json_decode($this->request->getJSON(), true);
|
||||||
log_message('critical', "Enpoint LOC2-> ".$endpoint );
|
log_message('critical', "Enpoint LOC2-> ".$endpoint );
|
||||||
switch ($endpoint) {
|
switch ($endpoint) {
|
||||||
case 'faq':
|
case 'login':
|
||||||
$res1 = (new \App\Models\faqData())->getSiteFaq([]);
|
$res1 = $this->dummyData($raw_array);
|
||||||
break;
|
break;
|
||||||
case 'blogdata':
|
|
||||||
$res1 = $this->blogData($endpoint,$raw_array);
|
|
||||||
break;
|
|
||||||
case 'contact':
|
|
||||||
$res1 = $this->contact($raw_array);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response->setJson($res1);
|
return $this->response->setJson($res1);
|
||||||
@@ -161,78 +82,4 @@ class FloatUserWeb extends BaseController
|
|||||||
'raw_data' => $raw_array,
|
'raw_data' => $raw_array,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function contact($raw_array)
|
|
||||||
{
|
|
||||||
/*$inx = array(
|
|
||||||
'name' => $this->post('name'),
|
|
||||||
'email' => $this->post('email'),
|
|
||||||
'country' => $this->post('country'),
|
|
||||||
'phone' => $this->post('phone'),
|
|
||||||
'message' => $this->post('message')
|
|
||||||
);
|
|
||||||
$something = $this->request->getVar('name');
|
|
||||||
*/
|
|
||||||
// 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');
|
|
||||||
$startInsert = false;
|
|
||||||
$status = 0;
|
|
||||||
$message_id = '';
|
|
||||||
// $raw_json = file_get_contents('php://input');
|
|
||||||
// $raw_array = json_decode($raw_json, true);
|
|
||||||
// $something = $raw_array['name'];
|
|
||||||
|
|
||||||
$db = \Config\Database::connect('float_site');
|
|
||||||
if (
|
|
||||||
$raw_array['country'] != '' &&
|
|
||||||
$raw_array['email'] != '' &&
|
|
||||||
$raw_array['name'] != '' &&
|
|
||||||
$raw_array['message'] != '' &&
|
|
||||||
$raw_array['phone'] != ''
|
|
||||||
) {
|
|
||||||
$startInsert = true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$status = -2;
|
|
||||||
$message_id = 'Parameters not recieved';
|
|
||||||
}
|
|
||||||
$data = [
|
|
||||||
'country' => $raw_array['country'],
|
|
||||||
'email' => $raw_array['email'],
|
|
||||||
'name' => $raw_array['name'],
|
|
||||||
'message' => $raw_array['message'],
|
|
||||||
'phone' => $raw_array['phone'],
|
|
||||||
];
|
|
||||||
|
|
||||||
if ($startInsert) {
|
|
||||||
try {
|
|
||||||
$db->table('myfit_contact')->insert($data);
|
|
||||||
// $insert_id = $db->affectedRows();
|
|
||||||
$insert_id = $db->insertId();
|
|
||||||
$query = $db->query(
|
|
||||||
'SELECT uuid, id FROM myfit_contact WHERE id = ' .
|
|
||||||
$insert_id
|
|
||||||
);
|
|
||||||
$row = $query->getRow();
|
|
||||||
$message_id = $row->uuid;
|
|
||||||
$status = $row->id;
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$status = -1;
|
|
||||||
$message_id = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$inx = [
|
|
||||||
'message_id' => $message_id,
|
|
||||||
'status' => $status,
|
|
||||||
];
|
|
||||||
return $inx;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,17 +27,19 @@ class FloatWeb extends BaseController
|
|||||||
WHERE
|
WHERE
|
||||||
p1.post_status='publish'
|
p1.post_status='publish'
|
||||||
AND p1.post_type='post'
|
AND p1.post_type='post'
|
||||||
ORDER BY p1.post_date DESC LIMIT 1000";
|
ORDER BY p1.post_date DESC LIMIT 2000";
|
||||||
|
|
||||||
$query = $this->db->query($mysql);
|
$query = $this->db->query($mysql);
|
||||||
|
|
||||||
$data['payload']['blogdata'] = $query->getResult('array');
|
$data['payload']['blogdata'] = $query->getResult('array');
|
||||||
|
$totalCount = count( $data['payload']['blogdata'] );
|
||||||
|
|
||||||
$randomIndex = rand(1, count($data['payload']['blogdata'] ));
|
$randomIndex = rand(1, $totalCount);
|
||||||
|
|
||||||
$data['payload']['featured'] = $data['payload']['blogdata'][$randomIndex ];
|
$data['payload']['featured'] = $data['payload']['blogdata'][$randomIndex ];
|
||||||
$data['payload']['image_url'] = 'https://blog.float.sg/wp-content/uploads/';
|
$data['payload']['image_url'] = 'https://blog.float.sg/wp-content/uploads/';
|
||||||
$data['payload']['blog_url'] = 'https://blog.float.sg/';
|
$data['payload']['blog_url'] = 'https://blog.float.sg/';
|
||||||
|
$data['payload']['total'] = $totalCount;
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user