Hi David,
It's been a while, hope you are well. I've been out of the game for a while but am now finding some time to do a bit of tinkering again with my sites and have the following question...
How easy would it be to knock up a management front-end for editing config.php? I've expanded this file quite considerably to hold all sorts of config information to make it easier to generate new sites but the one thing that would be really helpful would be a web front end to edit this file. Do you know of a simple way of doing this? Just loading the text file in to a window where it can be edited and then saved would be all that's needed, in the same way that in Wordpress you can open .php plugins to edit.
Any ideas please?
Cheers.
Keeop
Nice one! Does the job perfectly - thanks David.
Keeop
Hi Keeop,
A basic editor is straight forward; have a go with the following as
admin/configeditor.php:
<?php
set_time_limit(0);
require("../includes/common.php");
$admin_checkPassword = TRUE;
require("../includes/admin.php");
if ($_POST["submit"]=="Save")
{
$fp = fopen("../config.php","w") or die("Could not open config.php for writing!");
fwrite($fp,$_POST["body"]);
header("Location: index.php");
exit();
}
require("admin_header.php");
require("admin_menu.php");
print "<h2>Config Editor</h2>";
print "<form method='post'>";
print "<textarea name='body' style='width:100%;height:500px;'>";
print htmlentities(file_get_contents("../config.php"));
print "</textarea>";
print "<input type='submit' name='submit' value='Save' />";
print "</form>";
require("admin_footer.php");
?>
You will need to make sure that config.php is writable by PHP - easiest way us normally via your FTP program. In the remote window, right-click on config.php and select Permissions, or maybe Properties... and then Permissions; then give WRITE access to all users (owner / group / world). Note that these are file system permissions; they're not [directly] related to any kind of over the web access; although I would still recommend removing world write access once you have finished configuration of a site.
Don't forget to make a backup of your config.php first just incase!!
Cheers,
David.
--
PriceTapestry.com