From 691726b630adbd4de5d5723ed4c2e62804df66fb Mon Sep 17 00:00:00 2001 From: dev-chiefworks Date: Sun, 12 Mar 2023 10:38:47 -0400 Subject: [PATCH] cache commit --- .gitignore | 3 ++ app/Config/Cache.php | 30 ++++++++++++++++- app/Config/Routes.php | 4 +++ app/Controllers/Home.php | 62 ++++++++++++++++++++++++++++++++++++ app/Controllers/Projects.php | 44 +++++++++++++++++++++++++ app/Views/projects/index.php | 4 +-- composer.json | 10 ++++-- 7 files changed, 152 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 016592d..8866057 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,9 @@ $RECYCLE.BIN/ .vagrant Vagrantfile +system +system/* + apache_log #------------------------- diff --git a/app/Config/Cache.php b/app/Config/Cache.php index 2d1fea9..88d2235 100644 --- a/app/Config/Cache.php +++ b/app/Config/Cache.php @@ -22,7 +22,7 @@ class Cache extends BaseConfig * * @var string */ - public $handler = 'file'; + public $handler = 'redis'; // 'file'; /** * -------------------------------------------------------------------------- @@ -152,13 +152,41 @@ class Cache extends BaseConfig * * @var array */ + public $redis = [ + 'host' => '10.0.0.32', + 'password' => 'adae59706edf22f9f61180578cd16cc2038703c7230ae012e3c783ace1d09d64', + 'port' => 6379, + 'timeout' => 0, + 'database' => 0, + ]; + + /* + 7f079034e166ecf52d82cbec9876e4dc8a154b0c37248f3fa1734d4eeab938d5 + + public $redis = [ + 'host' => '10.0.0.32', + 'password' => '7f079034e166ecf52d82cbec9876e4dc8a154b0c37248f3fa1734d4eeab938d5', + 'port' => 6378, + 'timeout' => 0, + 'database' => 0, + ]; + + public $redis = [ + 'host' => '10.0.0.32', + 'password' => 'adae59706edf22f9f61180578cd16cc2038703c7230ae012e3c783ace1d09d64', + 'port' => 6379, + 'timeout' => 0, + 'database' => 0, + ]; + public $redis = [ 'host' => '127.0.0.1', 'password' => null, 'port' => 6379, 'timeout' => 0, 'database' => 0, ]; + */ /** * -------------------------------------------------------------------------- diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 28cb151..6b9cf31 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -34,8 +34,12 @@ $routes->setAutoRoute(true); $routes->get('/', 'Home::index'); +$routes->get('/projects', 'Home::projectstart'); + $routes->get('/startproject', 'Projects::start'); $routes->post('/startproject', 'Projects::start'); +$routes->get('/projects/dash', 'Projects::start'); + /* * -------------------------------------------------------------------- * Additional Routing diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 0860262..c2aaba2 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -1,11 +1,55 @@ pushHandler($handler); + + + // Create the logger + $this->logger = new Logger($_SERVER['SERVER_ADDR']); + + // Create Graylog GELF TCP transport + $transport = new Gelf\Transport\TcpTransport("10.0.0.112",12201); + + // Create GELF handler + $handler = new GelfHandler(new Gelf\Publisher($transport)); + + // Now add GELF handler to logger + $this->logger->pushHandler($handler); + + // You can now use your logger + $logger->info('My logger is now ready'); + + + + $cache = \Config\Services::cache(); + $blog_array_cache = $cache->get('blog_array'); + + var_dump($cache->getMetadata('ameye')); +*/ + + $data=array(); $this->db = \Config\Database::connect($this->con_name); @@ -35,6 +79,19 @@ class Home extends BaseController } + if (! $blog_array_cache = cache('blog_array')) { + // echo 'Saving to the cache!
'; + // $foo = 'foobarbaz!'; + + // Save into the cache for 5 minutes + + // cache()->save('blog_array', $data["blog_array"], 300); + // cache()->save('ameye', 'testing_ameye', 300); + } + + // var_dump($cache->getCacheInfo()); + // var_dump($cache->redis->is_supported()); + // featured try { $mysql = "SELECT id, post_title, post_content,post_date,comment_count @@ -51,4 +108,9 @@ class Home extends BaseController //return view('welcome_message'); return view('chiefsoft',$data); } + + public function projectstart() + { + return view('projects/index'); + } } diff --git a/app/Controllers/Projects.php b/app/Controllers/Projects.php index cee6678..ebb384a 100644 --- a/app/Controllers/Projects.php +++ b/app/Controllers/Projects.php @@ -11,6 +11,50 @@ class Projects extends BaseController public function start() { + $request = \Config\Services::request(); + + if ($request->getMethod() == 'post') { + $out = []; + $username = trim($request->getPost('username')); + $password = trim($request->getPost('password')); + if ($this->loginUser($username, $password, $out) == true) { + $segments = ['dash']; + return redirect()->to(site_url($segments)); + } + } else { + return view('welcome_message'); + } + return view('projects/index'); } + + private function loginUser($username, $password, &$out) + { + $loginComplete = false; + //entries sent + if ($username == '' || $password == '') { + $loginComplete = false; + $out['error'] = 'All parameters required'; + } + if ($username == 'support@chiefsoft.com' && $password == '12345678') { + $loginComplete = true; + $out['username'] = 'ameye@chiefsoft.com'; + $out['firstname'] = 'Olusesan'; + $out['lastname'] = 'Ameye'; + $out['uid'] = 'gdgdgdgd-dhdhshdh-gshshshhs-hdhdhuu'; + $out['id'] = '100'; + // $_SESSION['bko_session'] = rand(10000,9999999).'-hhdsdyuyu487484398439843jjhjfhjfdhjfdhjfdhj89498498598jfjfhjf'; + // $_SESSION['bko_user'] = $out; + + Services::session()->set([ + 'bko_user' => $out, + 'bko_session' => rand(10000,9999999).'-hhdsdyuyu487484398439843jjhjfhjfdhjfdhjfdhj89498498598jfjfhjf', + 'lastName'=> $out['lastname'], + 'firstName'=> $out['firstname'], + 'username'=> $out['username'] + ]); + } + + return $loginComplete; + } } diff --git a/app/Views/projects/index.php b/app/Views/projects/index.php index 409f402..8f93f60 100644 --- a/app/Views/projects/index.php +++ b/app/Views/projects/index.php @@ -53,7 +53,7 @@
- +
@@ -62,7 +62,7 @@
- + diff --git a/composer.json b/composer.json index 25ac1f0..c2b4203 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,11 @@ "ext-mbstring": "*", "kint-php/kint": "^4.0", "laminas/laminas-escaper": "^2.9", - "psr/log": "^1.1" + "psr/log": "^1.1", + "predis/predis": "^1.1", + "paragonie/sodium_compat": "^1.17", + "monolog/monolog": "^2.8", + "graylog2/gelf-php": "^1.7" }, "require-dev": { "codeigniter/coding-standard": "^1.1", @@ -24,7 +28,9 @@ "predis/predis": "^1.1" }, "suggest": { - "ext-fileinfo": "Improves mime type detection for files" + "ext-fileinfo": "Improves mime type detection for files", + "ext-redis": "If you use Cache class RedisHandler", + "paragonie/random_compat": "Provides better randomness in PHP 5.x" }, "autoload": { "psr-4": {