diff --git a/www-api/app/Config/Boot/development.php b/www-api/app/Config/Boot/development.php index 05a86125..56246243 100644 --- a/www-api/app/Config/Boot/development.php +++ b/www-api/app/Config/Boot/development.php @@ -30,3 +30,7 @@ defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true); | items. It can always be used within your own application too. */ defined('CI_DEBUG') || define('CI_DEBUG', true); + +define('ENV_ID', 'DEVLP20233103-A3'); +define('HOME_PAGE_BACKGROUND', 'api_bk.jpg'); +define('CACHE_DOMAIN', 'wrench.dev'); \ No newline at end of file diff --git a/www-api/app/Config/Boot/production.php b/www-api/app/Config/Boot/production.php index 21d25805..771bb4f1 100644 --- a/www-api/app/Config/Boot/production.php +++ b/www-api/app/Config/Boot/production.php @@ -19,3 +19,7 @@ error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & | release of the framework. */ defined('CI_DEBUG') || define('CI_DEBUG', false); + +define('ENV_ID', 'PRAODUCTIONG20233103-A3'); +define('HOME_PAGE_BACKGROUND', 'api_bk.jpg'); +define('CACHE_DOMAIN', 'wrench.prod'); \ No newline at end of file diff --git a/www-api/app/Config/Boot/testing.php b/www-api/app/Config/Boot/testing.php index e07a1d43..6e74906d 100644 --- a/www-api/app/Config/Boot/testing.php +++ b/www-api/app/Config/Boot/testing.php @@ -30,3 +30,7 @@ defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true); | release of the framework. */ defined('CI_DEBUG') || define('CI_DEBUG', true); + +define('ENV_ID', 'TESTING20233103-A3'); +define('HOME_PAGE_BACKGROUND', 'api_bk.jpg'); +define('CACHE_DOMAIN', 'wrench.test'); \ No newline at end of file diff --git a/www-api/app/Config/Cache.php b/www-api/app/Config/Cache.php index 2d1fea90..3dbea7a5 100644 --- a/www-api/app/Config/Cache.php +++ b/www-api/app/Config/Cache.php @@ -22,7 +22,7 @@ class Cache extends BaseConfig * * @var string */ - public $handler = 'file'; + public $handler = 'redis'; /** * -------------------------------------------------------------------------- @@ -35,7 +35,7 @@ class Cache extends BaseConfig * * @var string */ - public $backupHandler = 'dummy'; + public $backupHandler = 'file'; /** * -------------------------------------------------------------------------- @@ -153,11 +153,12 @@ class Cache extends BaseConfig * @var array */ public $redis = [ - 'host' => '127.0.0.1', - 'password' => null, - 'port' => 6379, + 'host' => '10.0.0.32', + 'password' => '7f079034e166ecf52d82cbec9876e4dc8a154b0c37248f3fa1734d4eeab938d5', + 'port' => 6378, 'timeout' => 0, 'database' => 0, + 'prefix' => 'WRB', ]; /** diff --git a/www-api/app/Config/Database.php b/www-api/app/Config/Database.php index 87d73b13..8f51e388 100644 --- a/www-api/app/Config/Database.php +++ b/www-api/app/Config/Database.php @@ -77,6 +77,25 @@ class Database extends Config 'foreignKeys' => true, ]; + public $wrench_blog = [ + 'DSN' => '', + 'hostname' => '10.10.33.60', + 'username' => 'float', + 'password' => 'float.user', + 'database' => 'float_blog', + '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 function __construct() { parent::__construct(); diff --git a/www-api/app/Controllers/WrenchApi.php b/www-api/app/Controllers/WrenchApi.php index e69de29b..9bb2fd1c 100644 --- a/www-api/app/Controllers/WrenchApi.php +++ b/www-api/app/Controllers/WrenchApi.php @@ -0,0 +1,13 @@ +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 2000"; + + $query = $this->db->query($mysql); + + $data['payload']['blogdata'] = $query->getResult('array'); + $totalCount = count( $data['payload']['blogdata'] ); + + $randomIndex = rand(1, $totalCount); + + $data['payload']['featured'] = $data['payload']['blogdata'][$randomIndex ]; + $data['payload']['image_url'] = 'https://blog.float.sg/wp-content/uploads/'; + $data['payload']['blog_url'] = 'https://blog.float.sg/'; + $data['payload']['total'] = $totalCount; + } catch (Exception $ex) { + + } + + 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() + { + + } + + +} \ No newline at end of file