I am developing the admin panel for my web application. The front end of the site is on a server separate from the admin panel. There is a form in the ACP where I want to be able to change the paths of my assets(img, js, css, etc) so all I have to do is change them in the form. A helper function I created will apply the saved URL to any template assets.
Since the frontend and admin panel are on different servers, I have to use file_get_contents with the FTP protocol to read the assets config file of the frontend from the admin panel. The file_get_contents function gets the content of the assets config file, but I want to be able to parse the actual PHP of the file and not just display the contents.
Example:
This is config/assets.php
<?php
$config = array(
'img' => 'http://localhost/frontend/assets/img',
'css' => 'http://localhost/frontend/assets/css',
'js' => 'http://localhost/frontend/assets/js',
'attachments' => 'http://localhost/frontend/attachments'
);
How can I use the information from the file above in the file below....
This is my MVC(CodeIgniter) controller:
<?php
class Assets extends MY_Controller {
function index(){
$this->load->library('form_validation');
if($this->form_validation->run('assets') == FALSE){
$this->template->overall_header("Asset Configuration");
$this->load->config('assets');
$config['acp'] = array(
'img_url' => $this->config->item('img_url'),
'css_url' => $this->config->item('css_url'),
'js_url' => $this->config->item('js_url'),
'attachment_url' => $this->config->item('attachment_url')
);
$this->load->config('ftp_frontend');
$content = file_get_contents('ftps://'.$this->config->item('username').':'.$this->config->item('password').'@'.$this->config->item('hostname').'/application/config/assets.php');
/------------------------------------------------------------------------------/
/----- Pass variables to the admin cp form from the content of the front -----/
/----- end assets config file ------------------------------------------------/
/------------------------------------------------------------------------------/
}
}
}
I hope I am explaining my problem well enough! Thanks!