Bruno B B Magalhães wrote:
Hi everybody,
well I don´t want to include and use those variables or set then. I
want to read the file, parse the vars to a form, so the user can change
the system configs using the web instead of FTP...
I am thinking reading using a simple include, and then clean the file
contents and write the strings..
Best Regards,
Bruno B B Magalhães
One simple way that I've done that in the past is to have a file, which
is a basic php file like:
?php
$INFO['prefix_sectionInForm'] = 'whatever';
?
Include that file then do
foreach( $INFO as $in_key = $in_val )
{
if( preg_match(/prefix_/, $in_key) )
{
$db_info[$in_key] = $in_val;
}
}
foreach( $db_info as $in_key = $in_val )
{
$text = ucfirst(substr( $in_key, however long the prefix is ));
$print Some descroptor based on the prefix.$text
input type='text' name='$in_key' value='in_val' /
}
Then just write it all back out on the form processor part, with some
security checking of course:
$file_string = ?php\n;
$update is an array with the key values I want..
foreach( $update as $info_key )
{
foreach( $input as $in_key = $in_val )
{
if( $info_key == $in_key )
{
$new[$info_key] = $in_val;
}
}
}
foreach( $new as $k = $v )
{
$file_string .= \$INFO[.'.$k.'.]\t\t\t=\t\.$v.\;\n;
}
$file_string .= \n.'?'.'';
Write $file_string back out to the config file.
Like I said, there's more to the script than this, error checks, seurity
checks and the like, but this is the 'meat' of it all.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php