diff --git a/app/Config/Database.php b/app/Config/Database.php index 7a1fd21..553a663 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -25,6 +25,28 @@ class Database extends Config * @var array */ public array $default = [ + 'DSN' => '', + 'hostname' => '10.20.30.60', + 'username' => 'merms_panel', + 'password' => 'merms_panel', + 'database' => 'merms_panel', + 'schema' => 'public', + 'DBDriver' => 'Postgre', + 'DBPrefix' => '', + 'pConnect' => false, + 'DBDebug' => true, + 'charset' => 'utf8', + 'swapPre' => '', + 'failover' => [], + 'port' => 5432, + 'dateFormat' => [ + 'date' => 'Y-m-d', + 'datetime' => 'Y-m-d H:i:s', + 'time' => 'H:i:s', + ], + ]; + + public array $default_old = [ 'DSN' => '', 'hostname' => 'localhost', 'username' => '', diff --git a/app/Config/Routes.php b/app/Config/Routes.php index fc4914a..a7b8ca2 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -6,3 +6,5 @@ use CodeIgniter\Router\RouteCollection; * @var RouteCollection $routes */ $routes->get('/', 'Home::index'); + +$routes->get('/provision/update', 'Home::provision'); diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 689405b..5bf018a 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -37,6 +37,7 @@ abstract class BaseController extends Controller */ protected $helpers = []; + protected $db; /** * Be sure to declare properties for any property fetch you initialized. * The creation of dynamic property is deprecated in PHP 8.2. @@ -52,7 +53,7 @@ abstract class BaseController extends Controller parent::initController($request, $response, $logger); // Preload any models, libraries, etc, here. - + $this->db = \Config\Database::connect(); // E.g.: $this->session = service('session'); } } diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 5934333..b6435ec 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -8,4 +8,35 @@ class Home extends BaseController { return view('welcome_message'); } + + public function provision(): string + { + $public_path = FCPATH; + $ansible_folder = str_replace("public/", "ANSIBLE", $public_path); + $mysql = "SELECT id, internal_url FROM members_products"; + $query = $this->db->query($mysql); + // $num = $query->num_rows(); + $provision_list= $query->getResult(); + //$provision_list =[]; + foreach ($provision_list as $pr){ + + $prov_name = str_replace(".", "_", $pr->internal_url).".yml"; + + $myfile = fopen( $ansible_folder ."/".$prov_name, "w") or die("Unable to open file!"); + $txt = "John Doe\n"; + fwrite($myfile, $txt); + $txt = "Jane Doe\n"; + fwrite($myfile, $txt); + fclose($myfile); + } + + // echo (__dir__); + + + + + + return view('welcome_message'); + } + } diff --git a/app/Views/welcome_message.php b/app/Views/welcome_message.php index c18eca3..8cba53c 100644 --- a/app/Views/welcome_message.php +++ b/app/Views/welcome_message.php @@ -28,7 +28,7 @@ text-rendering: optimizeLegibility; } header { - background-color: rgba(247, 248, 249, 1); + background-color: rgb(34, 113, 192); padding: .4rem 0 0; } .menu { @@ -198,134 +198,9 @@ } - + - -
- - - -
- -

Welcome to CodeIgniter

- -

The small framework with powerful features

- -
- -
- - - -
- -

About this page

- -

The page you are looking at is being generated dynamically by CodeIgniter.

- -

If you would like to edit this page you will find it located at:

- -
app/Views/welcome_message.php
- -

The corresponding controller for this page can be found at:

- -
app/Controllers/Home.php
- -
- -
- -
- -

Go further

- -

- - Learn -

- -

The User Guide contains an introduction, tutorial, a number of "how to" - guides, and then reference documentation for the components that make up - the framework. Check the User Guide !

- -

- - Discuss -

- -

CodeIgniter is a community-developed open source project, with several - venues for the community members to gather and exchange ideas. View all - the threads on CodeIgniter's forum, or chat on Slack !

- -

- - Contribute -

- -

CodeIgniter is a community driven project and accepts contributions - of code and documentation from the community. Why not - - join us ?

- -
- -
- - - - - - - - - - +MERMS Provision