Files
MermsProvision/app/Controllers/Home.php
T
CHIEFSOFT\ameye 2b7f61f103 template files
2025-01-18 23:25:43 -05:00

42 lines
1.1 KiB
PHP

<?php
namespace App\Controllers;
class Home extends BaseController
{
public function index(): string
{
return view('welcome_message');
}
public function provision(): string
{
$public_path = FCPATH;
$ansible_folder = str_replace("public/", "ANSIBLE", $public_path);
$mysql = "SELECT id, internal_url,product_id,status 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";
$template_file = $ansible_folder ."/templates/".$pr->product_id.".yml";
$template_content = file_get_contents($template_file);
$myfile = fopen( $ansible_folder ."/".$prov_name, "w") or die("Unable to open file!");
fwrite($myfile, $template_content);
fclose($myfile);
}
// echo (__dir__);
return view('welcome_message');
}
}