Welcome Guest, Not a member yet? Register   Sign In
How edit config field?
#3

(02-02-2020, 10:11 AM)InsiteFX Wrote: I played around with this a little today using CI 4 here is the code, should work for CI 3.

There is no error handling or checks but it doe's work.

I' am planning on writing a config file editor later when I have the time.

PHP Code:
public function index()
 {
 
$data = [];

 
// The path to the Config file.
 
$fileName APPPATH.'Config\App.php';

 
// Get the Config file contents.
 
$appConfig file_get_contents($fileName);

 
// The string to search for
 
$search  "public ".'$indexPage'." = 'index.php';";
 
 
// The string to replace string with.
 
$replace "public ".'$indexPage'." = '';";
 
 
// The subject is the whole file.
 
$subject $appConfig;

 
// Replace the string with new string value.
 
$ac str_replace($search$replace$subject);

 
// Write the file back out.
 
$result file_put_contents($fileName$ac);

 
/**
 * Dispaly the file in a textarea on output
 * 
 * <label>App Config</label><br>
 * <textarea rows="200" cols="143">
 *      <?php echo $config;?>
 * </textarea>
 */
 
 
$data['config'] = $ac;

 return 
view('welcome_message'$data);
 } 

At least it is something to get you started.

If you use the code make sure you add in protect and check for errors.

You will need to change the paths for CI 3.

I had guessed
Thanks
Reply


Messages In This Thread
How edit config field? - by omid_student - 02-02-2020, 06:08 AM
RE: How edit config field? - by InsiteFX - 02-02-2020, 10:11 AM
RE: How edit config field? - by omid_student - 02-02-2020, 10:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB